From 6eb205d591863f03e661f79ea3cb993f69eff844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Wed, 23 Nov 2022 18:20:57 +0000 Subject: [PATCH 1/6] bootstrap dist: ensure LLD's step --- src/bootstrap/dist.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 340aa78ebf9b5..479bfeb8e8565 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -2067,6 +2067,12 @@ impl Step for RustDev { builder.ensure(crate::native::Llvm { target }); + // If the config has LLD enabled, ensure its step. We'll we want to package it, and use it + // in download-ci-llvm. + if builder.config.lld_enabled { + builder.ensure(crate::native::Lld { target }); + } + let src_bindir = builder.llvm_out(target).join("bin"); // If updating this list, you likely want to change // src/bootstrap/download-ci-llvm-stamp as well, otherwise local users From 835b58d61971890c3134f1d7a6a23d32f3ae7479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Wed, 23 Nov 2022 18:08:15 +0000 Subject: [PATCH 2/6] make the `native::LLD` step able to use an already built lld Makes the lld step avoid building it from source when possible: when dist has packaged it along the other LLVM binaries for the rust-dev component. --- src/bootstrap/native.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 4e503dfe864e2..0f92c81e4d970 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -826,6 +826,20 @@ impl Step for Lld { let LlvmResult { llvm_config, llvm_cmake_dir } = builder.ensure(Llvm { target: self.target }); + // The `dist` step packages LLD next to LLVM's binaries for download-ci-llvm. The root path + // we usually expect here is `./build/$triple/ci-llvm/`, with the binaries in its `bin` + // subfolder. We check if that's the case, and if LLD's binary already exists there next to + // `llvm-config`: if so, we can use it instead of building LLVM/LLD from source. + let ci_llvm_bin = llvm_config.parent().unwrap(); + if ci_llvm_bin.is_dir() && ci_llvm_bin.file_name().unwrap() == "bin" { + let lld_path = ci_llvm_bin.join(exe("lld", target)); + if lld_path.exists() { + // The following steps copying `lld` as `rust-lld` to the sysroot, expect it in the + // `bin` subfolder of this step's out dir. + return ci_llvm_bin.parent().unwrap().to_path_buf(); + } + } + let out_dir = builder.lld_out(target); let done_stamp = out_dir.join("lld-finished-building"); if done_stamp.exists() { From 4e4658f0aafbf559a2c3e8674f10a06cadbfc737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Wed, 23 Nov 2022 18:12:58 +0000 Subject: [PATCH 3/6] slight cleanup --- src/bootstrap/native.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 0f92c81e4d970..48158d51e004c 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -823,8 +823,7 @@ impl Step for Lld { } let target = self.target; - let LlvmResult { llvm_config, llvm_cmake_dir } = - builder.ensure(Llvm { target: self.target }); + let LlvmResult { llvm_config, llvm_cmake_dir } = builder.ensure(Llvm { target }); // The `dist` step packages LLD next to LLVM's binaries for download-ci-llvm. The root path // we usually expect here is `./build/$triple/ci-llvm/`, with the binaries in its `bin` From f635f9d4e4448bbccca28a93e42ca52043edeb41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Wed, 23 Nov 2022 18:16:37 +0000 Subject: [PATCH 4/6] turn a comment into an actual doc comment --- src/bootstrap/native.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 48158d51e004c..781a738a81196 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -63,13 +63,13 @@ impl LdFlags { } } -// This returns whether we've already previously built LLVM. -// -// It's used to avoid busting caches during x.py check -- if we've already built -// LLVM, it's fine for us to not try to avoid doing so. -// -// This will return the llvm-config if it can get it (but it will not build it -// if not). +/// This returns whether we've already previously built LLVM. +/// +/// It's used to avoid busting caches during x.py check -- if we've already built +/// LLVM, it's fine for us to not try to avoid doing so. +/// +/// This will return the llvm-config if it can get it (but it will not build it +/// if not). pub fn prebuilt_llvm_config( builder: &Builder<'_>, target: TargetSelection, From c73a46c6bff445230a922e6b5e3018f87443bcbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Tue, 22 Nov 2022 22:38:53 +0000 Subject: [PATCH 5/6] bump download-ci-llvm-stamp --- src/bootstrap/download-ci-llvm-stamp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/download-ci-llvm-stamp b/src/bootstrap/download-ci-llvm-stamp index d19a1ae95cf14..94630e40f3c4c 100644 --- a/src/bootstrap/download-ci-llvm-stamp +++ b/src/bootstrap/download-ci-llvm-stamp @@ -1,4 +1,4 @@ Change this file to make users of the `download-ci-llvm` configuration download a new version of LLVM from CI, even if the LLVM submodule hasn’t changed. -Last change is for: https://github.com/rust-lang/rust/pull/102790 +Last change is for: https://github.com/rust-lang/rust/pull/104748 From e0f5c6da1df52a64b80753bf33bae3176729ae52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Tue, 3 Jan 2023 20:21:49 +0000 Subject: [PATCH 6/6] ensure lld's step unconditionally for RustDev component --- src/bootstrap/dist.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 479bfeb8e8565..68215790bed17 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -2067,11 +2067,8 @@ impl Step for RustDev { builder.ensure(crate::native::Llvm { target }); - // If the config has LLD enabled, ensure its step. We'll we want to package it, and use it - // in download-ci-llvm. - if builder.config.lld_enabled { - builder.ensure(crate::native::Lld { target }); - } + // We want to package `lld` to use it with `download-ci-llvm`. + builder.ensure(crate::native::Lld { target }); let src_bindir = builder.llvm_out(target).join("bin"); // If updating this list, you likely want to change