MVP for using rust-lld as part of cc by sledgehammervampire · Pull Request #85961 · rust-lang/rust (original) (raw)

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

sledgehammervampire

Will fix #71519. I need to figure out how to write a test showing that lld is used instead of whatever linker cc normally uses. When I manually run rustc using echo 'fn main() {}' | RUSTC_LOG=rustc_codegen_ssa:🔙:link=debug ./rustc -Clinker-flavor=gcc-lld --crate-type bin -Clink-arg=-Wl,-v (thanks to bjorn3 on Zulip), I can see that lld is used, but I'm not sure how to inspect that output in a test.

@rust-highfive

r? @davidtwco

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@sledgehammervampire

Hmm, it looks like the test passed on my machine because I had lld = true in my config.toml and used the rust-lld built by x.py.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

bjorn3

bjorn3

bjorn3

bjorn3

@rust-log-analyzer

This comment has been minimized.

bjorn3

bjorn3

bjorn3

bjorn3

bjorn3

bjorn3

@sledgehammervampire

ignore test if rust-lld not found

create ld -> rust-lld symlink at build time instead of run time

for testing in ci

copy instead of symlinking

remove linux check

test for linker, suggestions from bjorn3

fix overly restrictive lld matcher

use -Zgcc-ld flag instead of -Clinker-flavor

refactor code adding lld to gcc path

revert ci changes

suggestions from petrochenkov

rename gcc_ld to gcc-ld in dirs

@sledgehammervampire

I've fixed the conflict (it was just merging the import sets from the new master and my PR).

@petrochenkov

@bors

📌 Commit 2a76762 has been approved by petrochenkov

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Jun 10, 2021

@bors

@bors

@bors bors mentioned this pull request

Jun 11, 2021

@sledgehammervampire

@petrochenkov I was trying to dogfood my own PR, and I realized that I copied "rust-lld" as "rust-lld" instead of "ld" in gcc_ld_dir in src/bootstrap/dist.rs. Should I make a new PR?

Edit: I renamed "rust-lld" to "ld" in my local copy of the nightly toolchain and I get errors that look like

linking with `cc` failed: exit status: 1
<long cc invocation>
collect2: fatal error: execvp: No such file or directory

@petrochenkov

@1000teslas
Yes, pleas make a new PR.

I get errors that look like

Looks like the file passes the exists check, but then cannot actually be executed.
Could you check whether it has executable rights?

@sledgehammervampire

@petrochenkov

Looks like the file passes the exists check, but then cannot actually be executed. Could you check whether it has executable rights?

Are you talking about the copy of rust-lld as ld? If so, then yes.

JohnTitor added a commit to JohnTitor/rust that referenced this pull request

Jun 30, 2021

@JohnTitor

…chenkov

copy rust-lld as ld in dist

Fixes bug in rust-lang#85961. Linking seems to work for pure Rust projects, but not when a C library needs to be dynamically linked.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request

Aug 26, 2021

@Dylan-DPC

Make -Z gcc-ld=lld work for Apple targets

-Z gcc-ld=lld was introduced in rust-lang#85961. It does not work on Macos because lld needs be either named ld64 or passed -flavor darwin as the first two arguments in order to select the Mach-O flavor. Rust invokes cc (=clang) on Macos for linking which calls ld as linker binary and not ld64, so just creating an ld64 binary and modifying the search path with -B does not work.

In order to solve this patch does:

Fixes rust-lang#86945.

Manishearth added a commit to Manishearth/rust that referenced this pull request

Aug 27, 2021

@Manishearth

Make -Z gcc-ld=lld work for Apple targets

-Z gcc-ld=lld was introduced in rust-lang#85961. It does not work on Macos because lld needs be either named ld64 or passed -flavor darwin as the first two arguments in order to select the Mach-O flavor. Rust invokes cc (=clang) on Macos for linking which calls ld as linker binary and not ld64, so just creating an ld64 binary and modifying the search path with -B does not work.

In order to solve this patch does:

Fixes rust-lang#86945.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request

Aug 27, 2021

@Dylan-DPC

Make -Z gcc-ld=lld work for Apple targets

-Z gcc-ld=lld was introduced in rust-lang#85961. It does not work on Macos because lld needs be either named ld64 or passed -flavor darwin as the first two arguments in order to select the Mach-O flavor. Rust invokes cc (=clang) on Macos for linking which calls ld as linker binary and not ld64, so just creating an ld64 binary and modifying the search path with -B does not work.

In order to solve this patch does:

Fixes rust-lang#86945.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request

Aug 27, 2021

@Dylan-DPC

Make -Z gcc-ld=lld work for Apple targets

-Z gcc-ld=lld was introduced in rust-lang#85961. It does not work on Macos because lld needs be either named ld64 or passed -flavor darwin as the first two arguments in order to select the Mach-O flavor. Rust invokes cc (=clang) on Macos for linking which calls ld as linker binary and not ld64, so just creating an ld64 binary and modifying the search path with -B does not work.

In order to solve this patch does:

Fixes rust-lang#86945.

bors added a commit to rust-lang-ci/rust that referenced this pull request

Aug 29, 2021

@bors

Make -Z gcc-ld=lld work for Apple targets

-Z gcc-ld=lld was introduced in rust-lang#85961. It does not work on Macos because lld needs be either named ld64 or passed -flavor darwin as the first two arguments in order to select the Mach-O flavor. Rust invokes cc (=clang) on Macos for linking which calls ld as linker binary and not ld64, so just creating an ld64 binary and modifying the search path with -B does not work.

In order to solve this patch does:

Fixes rust-lang#86945.

@ghost ghost mentioned this pull request

Sep 12, 2021

@lqd lqd mentioned this pull request

Apr 14, 2022

3 tasks

@lqd lqd mentioned this pull request

May 18, 2024

@lqd lqd mentioned this pull request

Apr 30, 2025

Labels

merged-by-bors

This PR was explicitly merged by bors.

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.