bootstrap: use target's LLVM libdir when cross-compiling - #162170
Open
heiher wants to merge 1 commit into
Open
Conversation
Collaborator
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
`Cargo::cargo` adds LLVM's library search path to `rustflags` for `ToolRustcPrivate`/`Codegen` so that tools linking against compiler libraries can find `libLLVM`. However, it always queried `host_llvm_config()`, which resolves to the *host*'s `llvm-config` regardless of the requested `target`. When cross-compiling, this appends the host's LLVM libdir to the target's link flags, which can cause linking to fail. Only use `llvm-config --libdir` when `target` is the host. Otherwise, ensure the `Llvm` step for `target` and derive the libdir from its `root_dir()` instead of invoking `llvm-config`, since the resulting binary may not be executable on the host if it was built for a different target.
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Kobzol
reviewed
Sep 2, 2026
| .to_owned() | ||
| } else { | ||
| let llvm_output = self.ensure(Llvm { target }); | ||
| llvm_output.root_dir().join("lib").to_string_lossy().into_owned() |
Member
There was a problem hiding this comment.
Does this work also on macOS/Windows? That being said, it is surely better than passing the host LLVM libdir :)
Contributor
Author
There was a problem hiding this comment.
It seems to work on macOS/Windows, but I don't have an environment to verify it. Could we test it on CI?
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cargo::cargoadds LLVM's library search path torustflagsforToolRustcPrivate/Codegenso that tools linking against compiler libraries can findlibLLVM. However, it always queriedhost_llvm_config(), which resolves to the host'sllvm-configregardless of the requestedtarget. When cross-compiling, this appends the host's LLVM libdir to the target's link flags, which can cause linking to fail.Only use
llvm-config --libdirwhentargetis the host. Otherwise, ensure theLlvmstep fortargetand derive the libdir from itsroot_dir()instead of invokingllvm-config, since the resulting binary may not be executable on the host if it was built for a different target.