From 128344196ba5d7da8185e498706996a135849b5f Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 7 Oct 2022 11:24:02 -0700 Subject: [PATCH 1/4] Let llvm-config tell us where to find its tools --- src/bootstrap/native.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 9045354d0b20a..fcd4148145163 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -497,18 +497,13 @@ impl Step for Llvm { // https://llvm.org/docs/HowToCrossCompileLLVM.html if target != builder.config.build { - builder.ensure(Llvm { target: builder.config.build }); - // FIXME: if the llvm root for the build triple is overridden then we - // should use llvm-tblgen from there, also should verify that it - // actually exists most of the time in normal installs of LLVM. - let host_bin = builder.llvm_out(builder.config.build).join("bin"); + let llvm_config = builder.ensure(Llvm { target: builder.config.build }); + let llvm_bindir = output(Command::new(&llvm_config).arg("--bindir")); + let host_bin = Path::new(llvm_bindir.trim()); cfg.define("LLVM_TABLEGEN", host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION)); // LLVM_NM is required for cross compiling using MSVC cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION)); - cfg.define( - "LLVM_CONFIG_PATH", - host_bin.join("llvm-config").with_extension(EXE_EXTENSION), - ); + cfg.define("LLVM_CONFIG_PATH", llvm_config); if builder.config.llvm_clang { let build_bin = builder.llvm_out(builder.config.build).join("build").join("bin"); let clang_tblgen = build_bin.join("clang-tblgen").with_extension(EXE_EXTENSION); From 40e497fc9cc271e4935a68854c7888fb56fccb1e Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 7 Oct 2022 11:25:01 -0700 Subject: [PATCH 2/4] Add llvm-tblgen to rust-dev for cross-compiling --- src/bootstrap/dist.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 7eb8f8bbb30ed..5a7a193897bfa 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -2028,6 +2028,7 @@ impl Step for RustDev { "llvm-nm", "llvm-dwarfdump", "llvm-dis", + "llvm-tblgen", ] { tarball.add_file(src_bindir.join(exe(bin, target)), "bin", 0o755); } From c3277198a1feccef6d96c84e6d40665a49820e8f Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 7 Oct 2022 11:29:24 -0700 Subject: [PATCH 3/4] 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 2e11cf19c3f6a..d19a1ae95cf14 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/97550 +Last change is for: https://github.com/rust-lang/rust/pull/102790 From a027474ea6b424aa4101edc9d15d8ebe677783e9 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 7 Oct 2022 15:12:27 -0700 Subject: [PATCH 4/4] Don't run llvm-config in dry runs --- src/bootstrap/native.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index fcd4148145163..ea97ae4f65127 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -498,11 +498,16 @@ impl Step for Llvm { // https://llvm.org/docs/HowToCrossCompileLLVM.html if target != builder.config.build { let llvm_config = builder.ensure(Llvm { target: builder.config.build }); - let llvm_bindir = output(Command::new(&llvm_config).arg("--bindir")); - let host_bin = Path::new(llvm_bindir.trim()); - cfg.define("LLVM_TABLEGEN", host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION)); - // LLVM_NM is required for cross compiling using MSVC - cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION)); + if !builder.config.dry_run { + let llvm_bindir = output(Command::new(&llvm_config).arg("--bindir")); + let host_bin = Path::new(llvm_bindir.trim()); + cfg.define( + "LLVM_TABLEGEN", + host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION), + ); + // LLVM_NM is required for cross compiling using MSVC + cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION)); + } cfg.define("LLVM_CONFIG_PATH", llvm_config); if builder.config.llvm_clang { let build_bin = builder.llvm_out(builder.config.build).join("build").join("bin");