Skip to content

Commit

Permalink
fix linux cross-compilation, take 2
Browse files Browse the repository at this point in the history
We were using `cfg!(target_arch)` checks, which are not correct, as
those check the architecture of the compiled build script, not the clang
target.
  • Loading branch information
froydnj committed May 17, 2017
1 parent abb2985 commit 5361544
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions components/style/build_gecko.rs
Expand Up @@ -153,14 +153,16 @@ mod bindings {
}
if cfg!(target_os = "linux") {
builder = builder.clang_arg("-DOS_LINUX=1");
// We may be cross-compiling with a clang that defaults to
// a different architecture, so we should explicitly specify
// the bitness being used here. Specifying --target instead
// leads to difficulties with LLVM search paths.
if cfg!(target_arch = "x86") {
builder = builder.clang_arg("-m32")
} else if cfg!(target_arch = "x86_64") {
builder = builder.clang_arg("-m64")
// cfg!(target_arch) will tell us the architecture that this .rs
// file is being compiled for. We want the architecture that
// the clang we're going to invoking is compiling for, which
// isn't necessarily the same thing. Cargo provides the
// (undocumented) CARGO_CFG_TARGET_ARCH for this purpose
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
if target_arch == "x86" {
builder = builder.clang_arg("-m32");
} else if target_arch == "x86_64" {
builder = builder.clang_arg("-m64");
}
} else if cfg!(target_os = "solaris") {
builder = builder.clang_arg("-DOS_SOLARIS=1");
Expand Down

0 comments on commit 5361544

Please sign in to comment.