-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Allow lld to be enabled on aarch64-unknown-linux-gnu
#146604
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 and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow lld to be enabled on aarch64-unknown-linux-gnu
#146604
Conversation
|
These commits modify compiler targets. |
|
rustbot has assigned @petrochenkov. Use |
aarch64-unknown-linux-gnulld to be enabled on aarch64-unknown-linux-gnu
|
cc @lqd If you have a spare cycle, do you have any insight to what the proper handling for this would be? |
|
The |
|
Targets already have strong control over what linker will get used and how, assuming no arguments are passed, so that seems good to me. |
Given that this environment variable is compile-time checked this would be sensible. Regardless of the direction this will require an update to |
|
The "quality" of lld support will vary per-target, so centralization is also a trade-off versus the signal the opt-in suggests in the target spec. I'm not sure the ergonomics are particularly useful to optimize, but why not in the future. The internals of relying on linker flavors should be moved to using linker features instead: this wasn't a blocker for stabilization but may be so if more targets want to do such a thing.
The maintainers for In addition to maybe waiting a bit to see how the first use of this turns out in practice when the next stable is released on Thursday, and what if anything needs to be changed in response. |
d5a84ce to
49dd168
Compare
|
This PR modifies If appropriate, please update |
49dd168 to
229be70
Compare
|
I made an update to the |
229be70 to
9cbfaae
Compare
9cbfaae to
358f344
Compare
I think we should have an option to use lld by default, but it should be different from the option to ship lld with the compiler. In particular, I suggest that we split the (Note that all of this is unrelated to |
|
We already have both
I agree that once more Linux targets than just x64 start switching to a different default linker, we should make this more first-class in bootstrap, rather than implicitly changing the behavior of I created an issue where we can discuss this further: #146640 |
|
☔ The latest upstream changes (presumably #146685) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@Hoverbear if you don't mind, I'd like to finish #146640 during next week, and prepare a way for targets to opt into LLD. Then this PR should become even smaller. |
|
@Kobzol sounds lovely. :) I'll adapt this once it lands. |
1733: Validate `-fuse-ld=lld` is passed, enable on aarch64 r=Hoverbear a=Hoverbear Also needed to edit the test harness to allow non-strict args. [I am upstreaming the aarch64 enablement as well.](rust-lang/rust#146604). -- I do not expect it to merge as is, as Upstream is changing some stuff to make this story better. :) This is manually backported to 1.90/25.11: #1804 1800: Add 25.11 release notes r=Hoverbear a=Hoverbear https://app.clickup.com/t/8699ur681 1816: Remove `compare_and_swap` from the subset r=Hoverbear a=pvdrz This function is deprecated and not having it in the subset allows us to not write tests to increase coverage for a function that our users aren't supposed to use Co-authored-by: Ana Hobden <[email protected]> Co-authored-by: Christian Poveda <[email protected]>
1733: Validate `-fuse-ld=lld` is passed, enable on aarch64 r=Hoverbear a=Hoverbear Also needed to edit the test harness to allow non-strict args. [I am upstreaming the aarch64 enablement as well.](rust-lang/rust#146604). -- I do not expect it to merge as is, as Upstream is changing some stuff to make this story better. :) This is manually backported to 1.90/25.11: #1804 1816: Remove `compare_and_swap` from the subset r=Hoverbear a=pvdrz This function is deprecated and not having it in the subset allows us to not write tests to increase coverage for a function that our users aren't supposed to use 1818: Update certification docs for new code coverage tooling (blanket) r=pvdrz a=Hoverbear Recreate #1817 Co-authored-by: Ana Hobden <[email protected]> Co-authored-by: Christian Poveda <[email protected]> Co-authored-by: Urhengulas <[email protected]> Co-authored-by: Johann Hemmann <[email protected]>
1733: Validate `-fuse-ld=lld` is passed, enable on aarch64 r=Hoverbear a=Hoverbear Also needed to edit the test harness to allow non-strict args. [I am upstreaming the aarch64 enablement as well.](rust-lang/rust#146604). -- I do not expect it to merge as is, as Upstream is changing some stuff to make this story better. :) This is manually backported to 1.90/25.11: #1804 1792: Add more tests to `coretests` r=Hoverbear a=pvdrz Improve coverage numbers. This will get upstreamed. 1816: Remove `compare_and_swap` from the subset r=Hoverbear a=pvdrz This function is deprecated and not having it in the subset allows us to not write tests to increase coverage for a function that our users aren't supposed to use Co-authored-by: Ana Hobden <[email protected]> Co-authored-by: Christian Poveda <[email protected]>
|
You can use the new system for configuring LLD for aarch64. |
|
Does that imply no changes need to be made here, then? I'll close this, then. Thanks so much. :) |
|
Yes, indeed. |
1733: Validate `-fuse-ld=lld` is passed, enable on aarch64 r=jyn514 a=Hoverbear Also needed to edit the test harness to allow non-strict args. [I am upstreaming the aarch64 enablement as well.](rust-lang/rust#146604). -- I do not expect it to merge as is, as Upstream is changing some stuff to make this story better. :) This is manually backported to 1.90/25.11: #1804 A basic smoke test: ```bash #! /usr/bin/env bash # Run from repo root set +eux SCRATCH=/tmp/dummy-scratch DIST=build/dist rm -rf $SCRATCH mkdir $SCRATCH rm -rf $DIST RUST_BACKTRACE=1 ./x.py --stage 2 dist rustc cargo llvm-tools rust-std ferrocene-self-test for folder in build/dist/*.tar.xz; do tar xvf $folder -C $SCRATCH done cd $SCRATCH ./bin/ferrocene-self-test ``` 1865: pull-subtrees: no longer modify git state just to update the index r=Hoverbear a=jyn514 See similar existing code in `ferrocene/tools/pull-upstream/pull.sh:89`. I tested locally that this runs ok using the steps in ferrocene/doc/internal-procedures/src/subtree-pulls.rst#reproducing-failures. Co-authored-by: Ana Hobden <[email protected]> Co-authored-by: Ana Hobden <[email protected]> Co-authored-by: Jynn Nelson <[email protected]>
1733: Validate `-fuse-ld=lld` is passed, enable on aarch64 r=jyn514 a=Hoverbear Also needed to edit the test harness to allow non-strict args. [I am upstreaming the aarch64 enablement as well.](rust-lang/rust#146604). -- I do not expect it to merge as is, as Upstream is changing some stuff to make this story better. :) This is manually backported to 1.90/25.11: #1804 A basic smoke test: ```bash #! /usr/bin/env bash # Run from repo root set +eux SCRATCH=/tmp/dummy-scratch DIST=build/dist rm -rf $SCRATCH mkdir $SCRATCH rm -rf $DIST RUST_BACKTRACE=1 ./x.py --stage 2 dist rustc cargo llvm-tools rust-std ferrocene-self-test for folder in build/dist/*.tar.xz; do tar xvf $folder -C $SCRATCH done cd $SCRATCH ./bin/ferrocene-self-test ``` Co-authored-by: Ana Hobden <[email protected]> Co-authored-by: Ana Hobden <[email protected]>
1733: Validate `-fuse-ld=lld` is passed, enable on aarch64 r=Hoverbear a=Hoverbear Also needed to edit the test harness to allow non-strict args. [I am upstreaming the aarch64 enablement as well.](rust-lang/rust#146604). -- I do not expect it to merge as is, as Upstream is changing some stuff to make this story better. :) This is manually backported to 1.90/25.11: #1804 A basic smoke test: ```bash #! /usr/bin/env bash # Run from repo root set +eux SCRATCH=/tmp/dummy-scratch DIST=build/dist rm -rf $SCRATCH mkdir $SCRATCH rm -rf $DIST RUST_BACKTRACE=1 ./x.py --stage 2 dist rustc cargo llvm-tools rust-std ferrocene-self-test for folder in build/dist/*.tar.xz; do tar xvf $folder -C $SCRATCH done cd $SCRATCH ./bin/ferrocene-self-test ``` 1864: core: Don't try to link darwin-specific doctest r=Hoverbear a=jyn514 This avoids the following error when running `$ ./x test core --doc --coverage=library -- objc::class`: ``` ---- library/core/src/os/darwin/objc.rs - os::darwin::objc::class (line 70) stdout ---- error: linking with `cc` failed: exit status: 1 | = note: "cc" "/var/folders/t3/46yqwwp56vg2jp1604qr5wd00000gn/T/rustczK8Mih/symbols.o" "<2 object files omitted>" "<sysroot>/lib/rustlib/aarch64-apple-darwin/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libprofiler_builtins-*,libcompiler_builtins-*}.rlib" "-lSystem" "-lc" "-lm" "-arch" "arm64" "-mmacosx-version-min=11.0.0" "-L" "<sysroot>-std/aarch64-apple-darwin/release/build/profiler_builtins-05da451c1827ec8e/out" "-o" "/Users/jyn/src/ferrocene3/build/ferrocene/coverage/doctests-bins/library_core_src_os_darwin_objc_rs_70_0/rust_out" "-Wl,-dead_strip" "-nodefaultlibs" = note: some arguments are omitted. use `--verbose` to show all linker arguments = note: Undefined symbols for architecture arm64: "_OBJC_CLASS_$_NSString", referenced from: in rust_out.rust_out.6d77164725c1f174-cgu.0.rcgu.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` 1865: pull-subtrees: no longer modify git state just to update the index r=Hoverbear a=jyn514 See similar existing code in `ferrocene/tools/pull-upstream/pull.sh:89`. I tested locally that this runs ok using the steps in ferrocene/doc/internal-procedures/src/subtree-pulls.rst#reproducing-failures. 1867: `rustc --version` reports the ferrocene version r=Hoverbear a=jyn514 Example output on a dev branch: ``` rustc 1.92.0-dev (Ferrocene rolling by Ferrous Systems) ``` Example output on a release branch: ``` rustc 1.90.0-dev (Ferrocene 25.11.0 by Ferrous Systems) ``` 1870: some text fixes to core cert docs r=Hoverbear a=tshepang Co-authored-by: Ana Hobden <[email protected]> Co-authored-by: Ana Hobden <[email protected]> Co-authored-by: Jynn Nelson <[email protected]> Co-authored-by: Tshepang Mbambo <[email protected]>
On Ferrocene, we set
rust.lld = trueand have recently added a check to validate that the-fuse-ld=lldargument is passed in ferrocene/ferrocene#1733. When running our tests I noticed theaarch64-unknown-linux-gnutarget was failing.Looking into it, I noticed that the aarch64 target lacks what the x86_64 target has in this regard:
rust/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs
Lines 23 to 28 in f3fd3ef
I adjusted the target to the included the related changes to Ferrocene and ran our full suite as well as validated the check from ferrocene/ferrocene#1733 also passes.
Testing
You can validate this by taking an
aarch64-unknown-linux-gnuhost with a config like:Validate that
rustcdoesn't pass anything aboutlld:Then, with a your toolchain link, as specified in the
rustc-dev-guide, run the following:Notice no output is provided. Next, using this branch:
./x.py build --stage 1 rustc +stage1 main.rs --print link-args | grep lldValidate how the output includes
-fuse-ld=lld.