-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
bootstrap: LLVM build disregards LDFLAGS #93880
Copy link
Copy link
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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_FLAGSis unset, CMake initializes it toLDFLAGS, but it does not considerLDFLAGSifCMAKE_EXE_LINKER_FLAGSis set. This means that Rust's LLVM bootstrap will sometimes respect (potentially required)LDFLAGSand 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 appendLDFLAGSfrom the environment to the value to retain parity with the behavior when the configuration isn't set.