diff options
| author | Jon Gjengset <jongje@amazon.com> | 2022-03-07 16:59:10 -0800 |
|---|---|---|
| committer | Jon Gjengset <jongje@amazon.com> | 2022-03-07 17:29:16 -0800 |
| commit | b328688d23d56a7b95ddcd994c3967a193dd25ea (patch) | |
| tree | f6073e7b1006aad2569f5c969f8f00d86c9f6046 /src/bootstrap | |
| parent | 89adcc636f94d34a6fc90fa117e28ddf6be7b983 (diff) | |
| download | rust-b328688d23d56a7b95ddcd994c3967a193dd25ea.tar.gz rust-b328688d23d56a7b95ddcd994c3967a193dd25ea.zip | |
Statically compile libstdc++ everywhere if asked
PR #93918 made it so that `-static-libstdc++` was only set in one place, and was only set during linking, but accidentally also made it so that it is no longer passed when building LLD or sanitizers, only when building LLVM itself. This moves the logic for setting `-static-libstdc++` in the linker flags back to `configure_cmake` so that it takes effect for all CMake invocations in `native.rs`. As a side-effect, this also causes libstdc++ to be statically compiled into sanitizers and LLD if `llvm-tools-enabled` is set but `llvm-static-stdcpp` is not, even though previously it was only linked statically if `llvm-static-stdcpp` was set explicitly. But that seems more like the expected behavior anyway.
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/native.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index f00c5ce5aa6..0fe39defae8 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -259,18 +259,6 @@ impl Step for Llvm { cfg.define("LLVM_LINK_LLVM_DYLIB", "ON"); } - // For distribution we want the LLVM tools to be *statically* linked to libstdc++. - // We also do this if the user explicitly requested static libstdc++. - if builder.config.llvm_tools_enabled || builder.config.llvm_static_stdcpp { - if !target.contains("msvc") && !target.contains("netbsd") { - if target.contains("apple") { - ldflags.push_all("-static-libstdc++"); - } else { - ldflags.push_all("-Wl,-Bsymbolic -static-libstdc++"); - } - } - } - if target.starts_with("riscv") && !target.contains("freebsd") { // RISC-V GCC erroneously requires linking against // `libatomic` when using 1-byte and 2-byte C++ @@ -576,6 +564,18 @@ fn configure_cmake( ldflags.push_all(&flags); } + // For distribution we want the LLVM tools to be *statically* linked to libstdc++. + // We also do this if the user explicitly requested static libstdc++. + if builder.config.llvm_tools_enabled || builder.config.llvm_static_stdcpp { + if !target.contains("msvc") && !target.contains("netbsd") { + if target.contains("apple") { + ldflags.push_all("-static-libstdc++"); + } else { + ldflags.push_all("-Wl,-Bsymbolic -static-libstdc++"); + } + } + } + cfg.define("CMAKE_SHARED_LINKER_FLAGS", &ldflags.shared); cfg.define("CMAKE_MODULE_LINKER_FLAGS", &ldflags.module); cfg.define("CMAKE_EXE_LINKER_FLAGS", &ldflags.exe); |
