Skip to content

Commit 21c6a0e

Browse files
authored
Rollup merge of #102790 - cuviper:llvm-tblgen, r=jyn514
Fix llvm-tblgen for cross compiling - Let llvm-config tell us where to find its tools - Add llvm-tblgen to rust-dev for cross-compiling Fixes #86890. r? ````@jyn514````
2 parents f1ab04f + a027474 commit 21c6a0e

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

src/bootstrap/dist.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2028,6 +2028,7 @@ impl Step for RustDev {
20282028
"llvm-nm",
20292029
"llvm-dwarfdump",
20302030
"llvm-dis",
2031+
"llvm-tblgen",
20312032
] {
20322033
tarball.add_file(src_bindir.join(exe(bin, target)), "bin", 0o755);
20332034
}

src/bootstrap/download-ci-llvm-stamp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Change this file to make users of the `download-ci-llvm` configuration download
22
a new version of LLVM from CI, even if the LLVM submodule hasn’t changed.
33

4-
Last change is for: https://github.com/rust-lang/rust/pull/97550
4+
Last change is for: https://github.com/rust-lang/rust/pull/102790

src/bootstrap/native.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -497,18 +497,18 @@ impl Step for Llvm {
497497

498498
// https://llvm.org/docs/HowToCrossCompileLLVM.html
499499
if target != builder.config.build {
500-
builder.ensure(Llvm { target: builder.config.build });
501-
// FIXME: if the llvm root for the build triple is overridden then we
502-
// should use llvm-tblgen from there, also should verify that it
503-
// actually exists most of the time in normal installs of LLVM.
504-
let host_bin = builder.llvm_out(builder.config.build).join("bin");
505-
cfg.define("LLVM_TABLEGEN", host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION));
506-
// LLVM_NM is required for cross compiling using MSVC
507-
cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION));
508-
cfg.define(
509-
"LLVM_CONFIG_PATH",
510-
host_bin.join("llvm-config").with_extension(EXE_EXTENSION),
511-
);
500+
let llvm_config = builder.ensure(Llvm { target: builder.config.build });
501+
if !builder.config.dry_run {
502+
let llvm_bindir = output(Command::new(&llvm_config).arg("--bindir"));
503+
let host_bin = Path::new(llvm_bindir.trim());
504+
cfg.define(
505+
"LLVM_TABLEGEN",
506+
host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION),
507+
);
508+
// LLVM_NM is required for cross compiling using MSVC
509+
cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION));
510+
}
511+
cfg.define("LLVM_CONFIG_PATH", llvm_config);
512512
if builder.config.llvm_clang {
513513
let build_bin = builder.llvm_out(builder.config.build).join("build").join("bin");
514514
let clang_tblgen = build_bin.join("clang-tblgen").with_extension(EXE_EXTENSION);

0 commit comments

Comments
 (0)