diff --git a/build.rs b/build.rs index 894508b5..5ccff76e 100644 --- a/build.rs +++ b/build.rs @@ -5,7 +5,9 @@ mod configure; use configure::{configure_f16_f128, Target}; fn main() { - println!("cargo:rerun-if-changed=build.rs"); + println!("cargo::rerun-if-changed=build.rs"); + println!("cargo::rerun-if-changed=configure.rs"); + let target = Target::from_env(); let cwd = env::current_dir().unwrap(); @@ -46,7 +48,7 @@ fn main() { // These targets have hardware unaligned access support. println!("cargo::rustc-check-cfg=cfg(feature, values(\"mem-unaligned\"))"); if target.arch.contains("x86_64") - || target.arch.contains("i686") + || target.arch.contains("x86") || target.arch.contains("aarch64") || target.arch.contains("bpf") { diff --git a/configure.rs b/configure.rs index 676c88f3..e23c0e83 100644 --- a/configure.rs +++ b/configure.rs @@ -2,6 +2,7 @@ use std::env; +#[derive(Debug)] #[allow(dead_code)] pub struct Target { pub triple: String, @@ -40,6 +41,11 @@ impl Target { .collect(), } } + + #[allow(dead_code)] + pub fn has_feature(&self, feature: &str) -> bool { + self.features.iter().any(|f| f == feature) + } } /// Configure whether or not `f16` and `f128` support should be enabled. diff --git a/testcrate/build.rs b/testcrate/build.rs index fde4e5b5..6205c7ac 100644 --- a/testcrate/build.rs +++ b/testcrate/build.rs @@ -14,6 +14,8 @@ mod builtins_configure { } fn main() { + println!("cargo::rerun-if-changed=../configure.rs"); + let target = builtins_configure::Target::from_env(); let mut features = HashSet::new(); @@ -27,7 +29,7 @@ fn main() { || (target.os == "windows" && target.env == "gnu") // FIXME(llvm): There is an ABI incompatibility between GCC and Clang on 32-bit x86. // See . - || target.arch == "i686" + || target.arch == "x86" // 32-bit PowerPC and 64-bit LE gets code generated that Qemu cannot handle. See // . || target.arch == "powerpc" @@ -41,7 +43,7 @@ fn main() { features.insert(Feature::NoSysF16F128Convert); } - if target.arch == "i586" || target.arch == "i686" { + if target.arch == "x86" { // 32-bit x86 does not have `__fixunstfti`/`__fixtfti` but does have everything else features.insert(Feature::NoSysF128IntConvert); // FIXME: 32-bit x86 has a bug in `f128 -> f16` system libraries @@ -55,7 +57,7 @@ fn main() { || target.arch == "powerpc" || target.arch == "powerpc64" || target.arch == "powerpc64le" - || target.arch == "i586" + || (target.arch == "x86" && !target.has_feature("sse")) || target.os == "windows" // Linking says "error: function signature mismatch: __extendhfsf2" and seems to // think the signature is either `(i32) -> f32` or `(f32) -> f32`. See @@ -72,11 +74,11 @@ fn main() { Feature::NoSysF128 => ("no-sys-f128", "using apfloat fallback for f128"), Feature::NoSysF128IntConvert => ( "no-sys-f128-int-convert", - "using apfloat fallback for f128 to int conversions", + "using apfloat fallback for f128 <-> int conversions", ), Feature::NoSysF16F128Convert => ( "no-sys-f16-f128-convert", - "skipping using apfloat fallback for f16 <-> f128 conversions", + "using apfloat fallback for f16 <-> f128 conversions", ), Feature::NoSysF16 => ("no-sys-f16", "using apfloat fallback for f16"), };