-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
bootstrap: LLVM build disregards LDFLAGS #93880
Comments
That makes sense to me, would be happy to accept a PR. It may also make sense to ask/file a similar bug against llvm recommending the logic to append always happen, since it seems like better behavior to me. |
I don't think this is really a bug in llvm; this is a standard CMAKE flag, and the observed behavior is expected behavior; changing it would be a breaking change to cmake sadly. I'd be happy to push a PR, though looking through the code raised a few other questions for me: First, when Lines 553 to 557 in 502d6aa
And since Line 354 in 502d6aa
It means that Second, the current bootstrap logic sets Line 247 in 502d6aa
Line 263 in 502d6aa
Line 312 in 502d6aa
Most of those are mutually exclusive, but when they're not, the later setting takes precedence. Is this intentional, or should the logic be fixed so that Anecdotally, we handle Lines 522 to 525 in 502d6aa
and same with CXXFLAGS :Lines 530 to 536 in 502d6aa
Third, it turns out we have a similar problem with |
I'm pretty sure that most of this behavior is unintentional and can largely be explained by incremental changes without really looking above/below in the file to make sure things aren't being set twice etc. I'm not particularly worried about breaking changes in bootstrap (e.g., if we start respecting LDFLAGS or CXXFLAGS etc), particularly when we're moving to what seems like relatively cleaner model. In general happy to see a PR that goes through and cleans the logic up. |
PR: #93918 |
…ark-Simulacrum bootstrap: tidy up flag handling for llvm build This tidies up the logic in `src/bootstrap/native.rs` such that: - `CMAKE_*_LINKER_FLAGS` is not overridden if we add to it twice. - `CMAKE_*_FLAGS` also include the standard `*FLAGS` environment variables, which CMake respects when we _don't_ set `CMAKE_*_FLAGS`. - `llvm.ldflags` from `config.toml` appends to the ldflags Rust's bootstrap logic adds, rather than replacing them. It also takes a second stab at rust-lang#89983 by moving `-static-libstdc++` to just be passed as a linker flag, since that's what it is. Fixes rust-lang#93880. Fixes rust-lang#70468. Closes rust-lang#89983.
When the bootstrap code builds LLVM, it sometimes sets the CMake variable
CMAKE_EXE_LINKER_FLAGS
. For example, when instructed to also build the LLVM tools:rust/src/bootstrap/native.rs
Lines 242 to 250 in 502d6aa
When
CMAKE_EXE_LINKER_FLAGS
is unset, CMake initializes it toLDFLAGS
, but it does not considerLDFLAGS
ifCMAKE_EXE_LINKER_FLAGS
is set. This means that Rust's LLVM bootstrap will sometimes respect (potentially required)LDFLAGS
and sometimes not depending on a number of unexpected factors, such as whether llvm tools are also being built, whether we're building for a non-FreeBSD RISC-V target, or if we're building forpowerpc-unknown-freebsd
. This, in turn, makes it difficult to bootstrap Rust in situations where additional linker flags are required, such as if dependencies are not stored in standard system-wide location such as/usr/lib
.I propose that anywhere we set
CMAKE_EXE_LINKER_FLAGS
, we appendLDFLAGS
from the environment to the value to retain parity with the behavior when the configuration isn't set.The text was updated successfully, but these errors were encountered: