bootstrap: use target's LLVM libdir when cross-compiling - #162170
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
| .to_owned() | ||
| } else { | ||
| let llvm_output = self.ensure(Llvm { target }); | ||
| llvm_output.root_dir().join("lib").to_string_lossy().into_owned() |
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 :)
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?
There was a problem hiding this comment.
Not sure if we actually cross-compile LLVM on CI somewhere on macOS/Windows. Let's try it.
There was a problem hiding this comment.
Wouldn't be hard if you want to try with something like https://github.com/rust-lang/rust/pull/148751/changes#diff-8291d819a8dc37b937e63c4e34dc5b27c59b1725e3ee677ffe0f970711d646df or windows-gnu.
This sounds like a recent-ish regression, as it seemed to work fine last year when gnullvm hosts were still cross-compiled from Linux.
6ef85c4 to
b1e1bc9
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
`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.
|
I think I was the directory also being named @bors r+ rollup=iffy |
bootstrap: use target's LLVM libdir when cross-compiling `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.
bootstrap: use target's LLVM libdir when cross-compiling `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.
bootstrap: use target's LLVM libdir when cross-compiling `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.
Rollup of 14 pull requests Successful merges: - #162324 (miri subtree update) - #162170 (bootstrap: use target's LLVM libdir when cross-compiling) - #158312 (Adds support for AArch64 SVE to inline assembly) - #159792 (A more readable debug map for IndexMaps) - #160745 (make closures act like MaybeDangling) - #161263 (break rustc_expand-rustc_middle dependency) - #161895 (std::sys::pal::sgx: fix mismatched alloc/free alignment) - #161940 (Promote `wasm32-wasip3` to a tier 2 target) - #161397 (coverage: Tidy tests and add some new ones) - #161616 (Report precondition violation for `<usize as SliceIndex>::get_unchecked` in const-eval) - #162248 (Add regression test for unsized const parameter default ICE) - #162250 (Fix hashing of span end columns in incremental compilation) - #162265 (cargotest: add lockfiles) - #162318 (bootstrap: Fix broken path for `./x doc compiler/rustc --open`)
Rollup merge of #162170 - heiher:fix-llvm-libdir, r=Kobzol bootstrap: use target's LLVM libdir when cross-compiling `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.
Rollup of 14 pull requests Successful merges: - rust-lang/rust#162324 (miri subtree update) - rust-lang/rust#162170 (bootstrap: use target's LLVM libdir when cross-compiling) - rust-lang/rust#158312 (Adds support for AArch64 SVE to inline assembly) - rust-lang/rust#159792 (A more readable debug map for IndexMaps) - rust-lang/rust#160745 (make closures act like MaybeDangling) - rust-lang/rust#161263 (break rustc_expand-rustc_middle dependency) - rust-lang/rust#161895 (std::sys::pal::sgx: fix mismatched alloc/free alignment) - rust-lang/rust#161940 (Promote `wasm32-wasip3` to a tier 2 target) - rust-lang/rust#161397 (coverage: Tidy tests and add some new ones) - rust-lang/rust#161616 (Report precondition violation for `<usize as SliceIndex>::get_unchecked` in const-eval) - rust-lang/rust#162248 (Add regression test for unsized const parameter default ICE) - rust-lang/rust#162250 (Fix hashing of span end columns in incremental compilation) - rust-lang/rust#162265 (cargotest: add lockfiles) - rust-lang/rust#162318 (bootstrap: Fix broken path for `./x doc compiler/rustc --open`)
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.