Fix compilation for AArch64
This commit is contained in:
parent
1bd9a132f6
commit
cda811173e
@ -115,10 +115,16 @@ pub(crate) fn build_sysroot(
|
||||
}
|
||||
}
|
||||
SysrootKind::Clif => {
|
||||
build_clif_sysroot_for_triple(channel, target_dir, target_triple);
|
||||
build_clif_sysroot_for_triple(channel, target_dir, host_triple, None);
|
||||
|
||||
if host_triple != target_triple {
|
||||
build_clif_sysroot_for_triple(channel, target_dir, host_triple);
|
||||
// When cross-compiling it is often necessary to manually pick the right linker
|
||||
let linker = if target_triple == "aarch64-unknown-linux-gnu" {
|
||||
Some("aarch64-linux-gnu-gcc")
|
||||
} else {
|
||||
None
|
||||
};
|
||||
build_clif_sysroot_for_triple(channel, target_dir, target_triple, linker);
|
||||
}
|
||||
|
||||
// Copy std for the host to the lib dir. This is necessary for the jit mode to find
|
||||
@ -133,7 +139,12 @@ pub(crate) fn build_sysroot(
|
||||
}
|
||||
}
|
||||
|
||||
fn build_clif_sysroot_for_triple(channel: &str, target_dir: &Path, triple: &str) {
|
||||
fn build_clif_sysroot_for_triple(
|
||||
channel: &str,
|
||||
target_dir: &Path,
|
||||
triple: &str,
|
||||
linker: Option<&str>,
|
||||
) {
|
||||
let build_dir = Path::new("build_sysroot").join("target").join(triple).join(channel);
|
||||
|
||||
let keep_sysroot =
|
||||
@ -155,6 +166,10 @@ fn build_clif_sysroot_for_triple(channel: &str, target_dir: &Path, triple: &str)
|
||||
build_cmd.arg("--release");
|
||||
rustflags.push_str(" -Zmir-opt-level=3");
|
||||
}
|
||||
if let Some(linker) = linker {
|
||||
use std::fmt::Write;
|
||||
write!(rustflags, " -Clinker={}", linker).unwrap();
|
||||
}
|
||||
build_cmd.env("RUSTFLAGS", rustflags);
|
||||
build_cmd.env(
|
||||
"RUSTC",
|
||||
|
10
src/lib.rs
10
src/lib.rs
@ -287,10 +287,12 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Box<dyn isa::Tar
|
||||
}
|
||||
None => {
|
||||
let mut builder =
|
||||
cranelift_codegen::isa::lookup_variant(target_triple, variant).unwrap();
|
||||
// Don't use "haswell" as the default, as it implies `has_lzcnt`.
|
||||
// macOS CI is still at Ivy Bridge EP, so `lzcnt` is interpreted as `bsr`.
|
||||
builder.enable("nehalem").unwrap();
|
||||
cranelift_codegen::isa::lookup_variant(target_triple.clone(), variant).unwrap();
|
||||
if target_triple.architecture == target_lexicon::Architecture::X86_64 {
|
||||
// Don't use "haswell" as the default, as it implies `has_lzcnt`.
|
||||
// macOS CI is still at Ivy Bridge EP, so `lzcnt` is interpreted as `bsr`.
|
||||
builder.enable("nehalem").unwrap();
|
||||
}
|
||||
builder
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user