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 }})
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.
r? @davidtwco
(rust-highfive has picked a reviewer for you, use r? to override)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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
.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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
I've fixed the conflict (it was just merging the import sets from the new master and my PR).
📌 Commit 2a76762 has been approved by petrochenkov
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
bors mentioned this pull request
@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
@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?
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
…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
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:
- Set the
lld_flavor
for all Apple-derived targets toLldFlavor::Ld64
. As far as I can see this actually works towards fixing-Xlinker=rust-lld
as all those targets use the Mach-O object format. - Copy/hardlink rust-lld to the gcc-ld subdirectory as ld64 next to ld.
- If
-Z gcc-ld=lld
is used and the target lld flavor is Ld64 add-fuse-ld=/path/to/ld64
to the linker invocation.
Fixes rust-lang#86945.
Manishearth added a commit to Manishearth/rust that referenced this pull request
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:
- Set the
lld_flavor
for all Apple-derived targets toLldFlavor::Ld64
. As far as I can see this actually works towards fixing-Xlinker=rust-lld
as all those targets use the Mach-O object format. - Copy/hardlink rust-lld to the gcc-ld subdirectory as ld64 next to ld.
- If
-Z gcc-ld=lld
is used and the target lld flavor is Ld64 add-fuse-ld=/path/to/ld64
to the linker invocation.
Fixes rust-lang#86945.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request
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:
- Set the
lld_flavor
for all Apple-derived targets toLldFlavor::Ld64
. As far as I can see this actually works towards fixing-Xlinker=rust-lld
as all those targets use the Mach-O object format. - Copy/hardlink rust-lld to the gcc-ld subdirectory as ld64 next to ld.
- If
-Z gcc-ld=lld
is used and the target lld flavor is Ld64 add-fuse-ld=/path/to/ld64
to the linker invocation.
Fixes rust-lang#86945.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request
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:
- Set the
lld_flavor
for all Apple-derived targets toLldFlavor::Ld64
. As far as I can see this actually works towards fixing-Xlinker=rust-lld
as all those targets use the Mach-O object format. - Copy/hardlink rust-lld to the gcc-ld subdirectory as ld64 next to ld.
- If
-Z gcc-ld=lld
is used and the target lld flavor is Ld64 add-fuse-ld=/path/to/ld64
to the linker invocation.
Fixes rust-lang#86945.
bors added a commit to rust-lang-ci/rust that referenced this pull request
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:
- Set the
lld_flavor
for all Apple-derived targets toLldFlavor::Ld64
. As far as I can see this actually works towards fixing-Xlinker=rust-lld
as all those targets use the Mach-O object format. - Copy/hardlink rust-lld to the gcc-ld subdirectory as ld64 next to ld.
- If
-Z gcc-ld=lld
is used and the target lld flavor is Ld64 add-fuse-ld=/path/to/ld64
to the linker invocation.
Fixes rust-lang#86945.
ghost mentioned this pull request
lqd mentioned this pull request
3 tasks
lqd mentioned this pull request
lqd mentioned this pull request
Labels
This PR was explicitly merged by bors.
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.