Skip to content

Commit

Permalink
Rollup merge of rust-lang#102790 - cuviper:llvm-tblgen, r=jyn514
Browse files Browse the repository at this point in the history
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 rust-lang#86890.
r? `@jyn514`
  • Loading branch information
matthiaskrgr authored Oct 8, 2022
2 parents b6e9ec6 + a027474 commit 87e219a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/download-ci-llvm-stamp
Original file line number Diff line number Diff line change
@@ -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
24 changes: 12 additions & 12 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,18 +497,18 @@ 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");
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),
);
let llvm_config = builder.ensure(Llvm { target: builder.config.build });
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");
let clang_tblgen = build_bin.join("clang-tblgen").with_extension(EXE_EXTENSION);
Expand Down

0 comments on commit 87e219a

Please sign in to comment.