From f22775b245f39fb0cec9b6279124a95b7fee7d03 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Wed, 19 Jun 2024 19:34:28 +0300 Subject: [PATCH 1/6] ignore `llvm::Lld` step if `lld` is not enabled People are having trouble 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. Signed-off-by: onur-ozkan --- src/bootstrap/src/core/build_steps/dist.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 54136d2aebda2..3c555f0a211cf 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -2261,9 +2261,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 @@ -2280,10 +2277,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); From 98854f7d3b954434a49b8dcdb3a196582c19c5b8 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Wed, 19 Jun 2024 19:53:28 +0300 Subject: [PATCH 2/6] add `lld = true` to default dist profile Make sure lld is enabled for dist profile unless it is explicitly disabled. Signed-off-by: onur-ozkan --- src/bootstrap/defaults/config.dist.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/defaults/config.dist.toml b/src/bootstrap/defaults/config.dist.toml index d06930f2b9d9b..d4feffe02271c 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 From ee76d70db0feb093d02b26e2ef1f5e5acb30e37d Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Thu, 27 Jun 2024 14:16:02 +0300 Subject: [PATCH 3/6] add change-tracker entry Signed-off-by: onur-ozkan --- src/bootstrap/src/utils/change_tracker.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index bfe3622e40d37..ccab25e55a9c3 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.", + }, ]; From ff9b8c136280a71281854e83e9f2e5e921d499ab Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Fri, 28 Jun 2024 11:24:16 +0300 Subject: [PATCH 4/6] ignore beta/stable channels on `rust-lld-by-default` test Signed-off-by: onur-ozkan --- tests/run-make/rust-lld-by-default/rmake.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/run-make/rust-lld-by-default/rmake.rs b/tests/run-make/rust-lld-by-default/rmake.rs index 5b065f86f53fb..94857a57dfb7c 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; From 56c7eb6135519241c00dd6435f7085068c3b14f9 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Wed, 19 Jun 2024 22:51:40 +0300 Subject: [PATCH 5/6] disable lld if external llvm is used Signed-off-by: onur-ozkan --- src/ci/run.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ci/run.sh b/src/ci/run.sh index efaf70078c4a9..869f75e923d2c 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 From 17b843bc2cc2db2bf86f2c93ec3bade5f358ba57 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Fri, 28 Jun 2024 20:32:31 +0300 Subject: [PATCH 6/6] update `run-make/windows-safeseh` compiletest header Signed-off-by: onur-ozkan --- tests/run-make/windows-safeseh/rmake.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run-make/windows-safeseh/rmake.rs b/tests/run-make/windows-safeseh/rmake.rs index 10e6b38aa8df1..c7c6ef7339d25 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;