-
Notifications
You must be signed in to change notification settings - Fork 13k
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
How to find LLD with old versions of gcc? #97402
Comments
A system where GCC is old enough that it doesn't support |
There is no |
No, there isn't. |
No idea, even if cargo caches some info about the environment, it does it implicitly, and the cache doesn't survive |
Everything cargo caches afaik is the output of |
LLD was usable earlier than that but I agree we shouldn't bother with them because they likely won't be able to correctly link Rust libraries. |
I've tried different gcc versions on |
If we don't need to support old versions then the main alternative to This would be nice in cases where we ship both classic LD and LLD, like with windows-gnu targets. Then we get the question (which is even more relevant to finding system-provided LLD).
|
That only works if you add the directory to the search path for toolchain tools using
Gcc can only be used for whichever target you compile it with. If you want to use gcc with an apple target you have to set it as target when compiling gcc. In that case I think it would look for ld64.lld. Same with wasm. For wasm32-unknown-none we directly call lld as there are no system libraries. For wasm32-wasi there is the wasi-sdk which I believe ships with clang and not gcc. |
Yes, I mean
I couldn't find such logic in GCC's source code. |
Update: turns out we cannot pass |
Note that: > brew search gcc offers a wide range of gccs: from v4.9 to v12 on my Mac. I never bothered to try them. My Apple clang is fine. |
Update: #100200 uses the strategy described in #97402 (comment) to fix #97755. |
…imulacrum Change implementation of `-Z gcc-ld` and `lld-wrapper` again This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
…imulacrum Change implementation of `-Z gcc-ld` and `lld-wrapper` again This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
…imulacrum Change implementation of `-Z gcc-ld` and `lld-wrapper` again This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
…imulacrum Change implementation of `-Z gcc-ld` and `lld-wrapper` again This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
…imulacrum Change implementation of `-Z gcc-ld` and `lld-wrapper` again This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
…imulacrum Change implementation of `-Z gcc-ld` and `lld-wrapper` again This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
…imulacrum Change implementation of `-Z gcc-ld` and `lld-wrapper` again This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
…imulacrum Change implementation of `-Z gcc-ld` and `lld-wrapper` again This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
…imulacrum Change implementation of `-Z gcc-ld` and `lld-wrapper` again This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
…imulacrum Change implementation of `-Z gcc-ld` and `lld-wrapper` again This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
…imulacrum Change implementation of `-Z gcc-ld` and `lld-wrapper` again This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
…imulacrum Change implementation of `-Z gcc-ld` and `lld-wrapper` again This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
Only specify `--target` by default for `-Zgcc-ld=lld` on wasm On macOS, it's not yet clear which cases of clang/OS/target/SDK version impact how to find ld/lld/rust-lld. The `--target` argument is not needed on our current targets with a vanilla config to do so, but may be in some cases ? That is, things look to be different and more subtle than suggested in rust-lang#97402 (comment). Specifying this argument unconditionally currently breaks `-Zgcc-ld=lld` on the 10.7+ targets on x64 macOS. Vanilla configs on x64 and aarch64 don't seem to need it to be able to find `rust-lld`. This fixes rust-lang#101653 on macOS (I've tried on x64 and aarch64: vanilla installs with the most recent command line tools available for each of the OS versions I have access to, `run-make/issue-71519` passes). I didn't expect the previous PRs to fail because of the existing tests, but CI does not actually run those tests yet, which explains the regressions. I was hoping to fix those in this PR but it's more involved (building lld is required for the tests to run, llvm/lld is not built on the test builders but on the dist builders, the dist builders don't run tests). This PR is just to unblock current users on macOS who have reported issues, but a regression could happen in the future by mistake until then. r? `@petrochenkov`
Only specify `--target` by default for `-Zgcc-ld=lld` on wasm On macOS, it's not yet clear which cases of clang/OS/target/SDK version impact how to find ld/lld/rust-lld. The `--target` argument is not needed on our current targets with a vanilla config to do so, but may be in some cases ? That is, things look to be different and more subtle than suggested in rust-lang/rust#97402 (comment). Specifying this argument unconditionally currently breaks `-Zgcc-ld=lld` on the 10.7+ targets on x64 macOS. Vanilla configs on x64 and aarch64 don't seem to need it to be able to find `rust-lld`. This fixes #101653 on macOS (I've tried on x64 and aarch64: vanilla installs with the most recent command line tools available for each of the OS versions I have access to, `run-make/issue-71519` passes). I didn't expect the previous PRs to fail because of the existing tests, but CI does not actually run those tests yet, which explains the regressions. I was hoping to fix those in this PR but it's more involved (building lld is required for the tests to run, llvm/lld is not built on the test builders but on the dist builders, the dist builders don't run tests). This PR is just to unblock current users on macOS who have reported issues, but a regression could happen in the future by mistake until then. r? `@petrochenkov`
The current strategy was implemented in #100200, closing. |
This issue is related to stabilizing use of LLD from rustc and/or making it default - rust-lang/compiler-team#510, #39915.
GCC and Clang have several ways to specify linker.
-B directory
, you specify a search directory, then the compiler finds a file namedld
in it an uses it as a linker.This is the old way working on all versions of GCC and Clang that we want to support (?).
-fuse-ld=bfd|gold|lld|mold
limited to 4 well-known linker names, you specify the name, then the compiler finds a file namedld.name
in its search directories.This is a somewhat new way, the well-known name
-fuse-ld=lld
works in Clang, and in GCC since 2018 (which GCC version?).-fuse-ld=/absolute/path/to/lld
, where you specify the full linker path.This doesn't work with GCC, and worked with Clang since 2016, but is now deprecated in favor of
--ld-path
.--ld-path=/absolute/path/to/lld
, where you specify the full linker path.This doesn't work with GCC, and works with Clang since 2021.
rustc
needs to tell C compiler to use LLD in two modesThis mode always uses
-B directory
right now (after Simplify implementation of-Z gcc-ld
#97375) just because it's simple to do, but it also means that old compilers are supported.QUESTIONS:
-fuse-ld=lld
?The text was updated successfully, but these errors were encountered: