Skip to content

Commit e9e6e2e

Browse files
committed
Auto merge of rust-lang#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
2 parents c4c0897 + 17b843b commit e9e6e2e

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

src/bootstrap/defaults/config.dist.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ download-ci-llvm = false
1616
# Make sure they don't get set when installing from source.
1717
channel = "nightly"
1818
download-rustc = false
19+
lld = true
1920
# Build the llvm-bitcode-linker
2021
llvm-bitcode-linker = true
2122

src/bootstrap/src/core/build_steps/dist.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -2270,9 +2270,6 @@ impl Step for RustDev {
22702270

22712271
builder.ensure(crate::core::build_steps::llvm::Llvm { target });
22722272

2273-
// We want to package `lld` to use it with `download-ci-llvm`.
2274-
builder.ensure(crate::core::build_steps::llvm::Lld { target });
2275-
22762273
let src_bindir = builder.llvm_out(target).join("bin");
22772274
// If updating this, you likely want to change
22782275
// src/bootstrap/download-ci-llvm-stamp as well, otherwise local users
@@ -2289,10 +2286,15 @@ impl Step for RustDev {
22892286
}
22902287
}
22912288

2292-
// We don't build LLD on some platforms, so only add it if it exists
2293-
let lld_path = builder.lld_out(target).join("bin").join(exe("lld", target));
2294-
if lld_path.exists() {
2295-
tarball.add_file(lld_path, "bin", 0o755);
2289+
if builder.config.lld_enabled {
2290+
// We want to package `lld` to use it with `download-ci-llvm`.
2291+
let lld_out = builder.ensure(crate::core::build_steps::llvm::Lld { target });
2292+
2293+
// We don't build LLD on some platforms, so only add it if it exists
2294+
let lld_path = lld_out.join("bin").join(exe("lld", target));
2295+
if lld_path.exists() {
2296+
tarball.add_file(lld_path, "bin", 0o755);
2297+
}
22962298
}
22972299

22982300
tarball.add_file(builder.llvm_filecheck(target), "bin", 0o755);

src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
195195
severity: ChangeSeverity::Warning,
196196
summary: "Removed `dist.missing-tools` configuration as it was deprecated long time ago.",
197197
},
198+
ChangeInfo {
199+
change_id: 126701,
200+
severity: ChangeSeverity::Warning,
201+
summary: "`llvm.lld` is enabled by default for the dist profile. If set to false, `lld` will not be included in the dist build.",
202+
},
198203
];

src/ci/run.sh

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ fi
8585
# space required for CI artifacts.
8686
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --dist-compression-formats=xz"
8787

88+
if [ "$EXTERNAL_LLVM" = "1" ]; then
89+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.lld=false"
90+
fi
91+
8892
# Enable the `c` feature for compiler_builtins, but only when the `compiler-rt` source is available
8993
# (to avoid spending a lot of time cloning llvm)
9094
if [ "$EXTERNAL_LLVM" = "" ]; then

tests/run-make/rust-lld-by-default/rmake.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// also be turned off with a CLI flag.
33

44
//@ needs-rust-lld
5+
//@ ignore-beta
6+
//@ ignore-stable
57
//@ only-x86_64-unknown-linux-gnu
68

79
use run_make_support::regex::Regex;

tests/run-make/windows-safeseh/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ only-windows
1+
//@ only-x86_64-pc-windows-msvc
22
//@ needs-rust-lld
33

44
use run_make_support::rustc;

0 commit comments

Comments
 (0)