Skip to content

Commit 6ccf03c

Browse files
committed
rustbuild: Fix 32-bit Windows build
Unfortunately on i686-pc-windows-gnu LLVM's answer to `--host-target` is `x86_64-pc-windows-gnu` even though we're building in a 32-bit shell as well as compiling 32-bit libraries. For now use Cargo's `HOST` environment variable to determine whether we're doing a cross compilation or not.
1 parent 0111892 commit 6ccf03c

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/librustc_llvm/build.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,20 @@ fn main() {
4747
// the host platform. This only really works if the host LLVM and target
4848
// LLVM are compiled the same way, but for us that's typically the case.
4949
//
50-
// We detect this cross compiling situation by asking llvm-config what it's
51-
// host-target is. If that's not the TARGET, then we're cross compiling.
52-
// This generally just means that we can't trust all the output of
53-
// llvm-config becaues it might be targeted for the host rather than the
54-
// target.
50+
// We *want* detect this cross compiling situation by asking llvm-config
51+
// what it's host-target is. If that's not the TARGET, then we're cross
52+
// compiling. Unfortunately `llvm-config` seems either be buggy, or we're
53+
// misconfiguring it, because the `i686-pc-windows-gnu` build of LLVM will
54+
// report itself with a `--host-target` of `x86_64-pc-windows-gnu`. This
55+
// tricks us into thinking we're doing a cross build when we aren't, so
56+
// havoc ensues.
57+
//
58+
// In any case, if we're cross compiling, this generally just means that we
59+
// can't trust all the output of llvm-config becaues it might be targeted
60+
// for the host rather than the target. As a result a bunch of blocks below
61+
// are gated on `if !is_crossed`
5562
let target = env::var("TARGET").unwrap();
56-
let host = output(Command::new(&llvm_config).arg("--host-target"));
57-
let host = host.trim();
63+
let host = env::var("HOST").unwrap();
5864
let is_crossed = target != host;
5965

6066
let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc",

0 commit comments

Comments
 (0)