about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-06-28 19:52:56 +0000
committerbors <bors@rust-lang.org>2024-06-28 19:52:56 +0000
commite9e6e2e444c30c23a9c878a88fbc3978c2acad95 (patch)
tree75f1cbc8abb76cbeae02e32aa20c8cc18ef48bd1
parentc4c0897a262d42f26f89aaca16ed52457f6a4f05 (diff)
parent17b843bc2cc2db2bf86f2c93ec3bade5f358ba57 (diff)
downloadrust-e9e6e2e444c30c23a9c878a88fbc3978c2acad95.tar.gz
rust-e9e6e2e444c30c23a9c878a88fbc3978c2acad95.zip
Auto merge of #126701 - onur-ozkan:build-lld-if-enabled, r=Kobzol
ignore `llvm::Lld` if lld is not enabled

People are having trouble ([ref. zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/MSVC.20Runtime.20mismatch.20when.20building.20LLD)) when they don't want to build `lld` for their custom distribution tarballs even with `lld = false` in their config.toml. This is because it is not controlled by `lld_enabled` flag. This change ensures that `llvm:Lld` is controlled by lld configuration.

Additionally, `lld = true` is set by default for dist profile, because we have been building it all along and this maintains that behavior.

try-job: x86_64-mingw
-rw-r--r--src/bootstrap/defaults/config.dist.toml1
-rw-r--r--src/bootstrap/src/core/build_steps/dist.rs16
-rw-r--r--src/bootstrap/src/utils/change_tracker.rs5
-rwxr-xr-xsrc/ci/run.sh4
-rw-r--r--tests/run-make/rust-lld-by-default/rmake.rs2
-rw-r--r--tests/run-make/windows-safeseh/rmake.rs2
6 files changed, 22 insertions, 8 deletions
diff --git a/src/bootstrap/defaults/config.dist.toml b/src/bootstrap/defaults/config.dist.toml
index d06930f2b9d..d4feffe0227 100644
--- a/src/bootstrap/defaults/config.dist.toml
+++ b/src/bootstrap/defaults/config.dist.toml
@@ -16,6 +16,7 @@ download-ci-llvm = false
 # Make sure they don't get set when installing from source.
 channel = "nightly"
 download-rustc = false
+lld = true
 # Build the llvm-bitcode-linker
 llvm-bitcode-linker = true
 
diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs
index 2dc7cd7de6a..0f24e91d81d 100644
--- a/src/bootstrap/src/core/build_steps/dist.rs
+++ b/src/bootstrap/src/core/build_steps/dist.rs
@@ -2270,9 +2270,6 @@ impl Step for RustDev {
 
         builder.ensure(crate::core::build_steps::llvm::Llvm { target });
 
-        // We want to package `lld` to use it with `download-ci-llvm`.
-        builder.ensure(crate::core::build_steps::llvm::Lld { target });
-
         let src_bindir = builder.llvm_out(target).join("bin");
         // If updating this, you likely want to change
         // src/bootstrap/download-ci-llvm-stamp as well, otherwise local users
@@ -2289,10 +2286,15 @@ impl Step for RustDev {
             }
         }
 
-        // We don't build LLD on some platforms, so only add it if it exists
-        let lld_path = builder.lld_out(target).join("bin").join(exe("lld", target));
-        if lld_path.exists() {
-            tarball.add_file(lld_path, "bin", 0o755);
+        if builder.config.lld_enabled {
+            // We want to package `lld` to use it with `download-ci-llvm`.
+            let lld_out = builder.ensure(crate::core::build_steps::llvm::Lld { target });
+
+            // We don't build LLD on some platforms, so only add it if it exists
+            let lld_path = lld_out.join("bin").join(exe("lld", target));
+            if lld_path.exists() {
+                tarball.add_file(lld_path, "bin", 0o755);
+            }
         }
 
         tarball.add_file(builder.llvm_filecheck(target), "bin", 0o755);
diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs
index bfe3622e40d..ccab25e55a9 100644
--- a/src/bootstrap/src/utils/change_tracker.rs
+++ b/src/bootstrap/src/utils/change_tracker.rs
@@ -195,4 +195,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
         severity: ChangeSeverity::Warning,
         summary: "Removed `dist.missing-tools` configuration as it was deprecated long time ago.",
     },
+    ChangeInfo {
+        change_id: 126701,
+        severity: ChangeSeverity::Warning,
+        summary: "`llvm.lld` is enabled by default for the dist profile. If set to false, `lld` will not be included in the dist build.",
+    },
 ];
diff --git a/src/ci/run.sh b/src/ci/run.sh
index efaf70078c4..869f75e923d 100755
--- a/src/ci/run.sh
+++ b/src/ci/run.sh
@@ -85,6 +85,10 @@ fi
 # space required for CI artifacts.
 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --dist-compression-formats=xz"
 
+if [ "$EXTERNAL_LLVM" = "1" ]; then
+  RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.lld=false"
+fi
+
 # Enable the `c` feature for compiler_builtins, but only when the `compiler-rt` source is available
 # (to avoid spending a lot of time cloning llvm)
 if [ "$EXTERNAL_LLVM" = "" ]; then
diff --git a/tests/run-make/rust-lld-by-default/rmake.rs b/tests/run-make/rust-lld-by-default/rmake.rs
index 5b065f86f53..94857a57dfb 100644
--- a/tests/run-make/rust-lld-by-default/rmake.rs
+++ b/tests/run-make/rust-lld-by-default/rmake.rs
@@ -2,6 +2,8 @@
 // also be turned off with a CLI flag.
 
 //@ needs-rust-lld
+//@ ignore-beta
+//@ ignore-stable
 //@ only-x86_64-unknown-linux-gnu
 
 use run_make_support::regex::Regex;
diff --git a/tests/run-make/windows-safeseh/rmake.rs b/tests/run-make/windows-safeseh/rmake.rs
index 10e6b38aa8d..c7c6ef7339d 100644
--- a/tests/run-make/windows-safeseh/rmake.rs
+++ b/tests/run-make/windows-safeseh/rmake.rs
@@ -1,4 +1,4 @@
-//@ only-windows
+//@ only-x86_64-pc-windows-msvc
 //@ needs-rust-lld
 
 use run_make_support::rustc;