about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-03-13 23:06:14 +0000
committerbors <bors@rust-lang.org>2022-03-13 23:06:14 +0000
commit737ef08ea066cbdc9f4b93373b1a1a108e6691ab (patch)
tree9586a01dca3120c02f47131874d31bcb06a2776c
parente95b10ba4ac4564ed25f7eef143e3182c33b3902 (diff)
parentca82e6cf18bb0f7765a978229f4899c33c5fdc7d (diff)
downloadrust-737ef08ea066cbdc9f4b93373b1a1a108e6691ab.tar.gz
rust-737ef08ea066cbdc9f4b93373b1a1a108e6691ab.zip
Auto merge of #94832 - jonhoo:default-static, r=Mark-Simulacrum
bootstrap: untangle static-libstdcpp & llvm-tools

Previously, the static-libstdcpp setting was tied to llvm-tools such
that enabling the latter always enabled the latter. This seems
unfortunate, since it is entirely reasonable for someone to want to
_not_ statically link stdc++, but _also_ want to build the llvm-tools.
This patch therefore separates the two settings such that neither
implies the other.

On its own, that would change the default behavior in a way that's
likely to surprise users. Specifically, users who build llvm-tools
_likely_ want those tools to be statically compiled against libstdc++,
since otherwise users with older GLIBCXX will be unable to run the
vended tools. So, we also flip the default for the `static-libstdcpp`
setting such that builds always link statically against libstdc++ by
default, but it's _possible_ to opt out.

See also #94719.
-rw-r--r--config.toml.example2
-rw-r--r--src/bootstrap/config.rs1
-rw-r--r--src/bootstrap/native.rs2
3 files changed, 3 insertions, 2 deletions
diff --git a/config.toml.example b/config.toml.example
index 466a3a29c4c..6e53d9b442f 100644
--- a/config.toml.example
+++ b/config.toml.example
@@ -89,7 +89,7 @@ changelog-seen = 2
 
 # Link libstdc++ statically into the rustc_llvm instead of relying on a
 # dynamic version to be available.
-#static-libstdcpp = false
+#static-libstdcpp = true
 
 # Whether to use Ninja to build LLVM. This runs much faster than make.
 #ninja = true
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index e744810295d..9534cc5f434 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -645,6 +645,7 @@ impl Config {
         config.llvm_optimize = true;
         config.ninja_in_file = true;
         config.llvm_version_check = true;
+        config.llvm_static_stdcpp = true;
         config.backtrace = true;
         config.rust_optimize = true;
         config.rust_optimize_tests = true;
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index 0fe39defae8..a810a57feb7 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -566,7 +566,7 @@ fn configure_cmake(
 
     // 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 builder.config.llvm_static_stdcpp {
         if !target.contains("msvc") && !target.contains("netbsd") {
             if target.contains("apple") {
                 ldflags.push_all("-static-libstdc++");