Skip to content

Commit b03b62e

Browse files
committed
fuzz: Add an assembly host implementation on x86
Add an implementation that accounts for rounding modes and checks status registers.
1 parent dc2b4d2 commit b03b62e

2 files changed

Lines changed: 587 additions & 53 deletions

File tree

fuzz/build.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ fn main() -> io::Result<()> {
2424
println!("cargo::rerun-if-changed=cxx");
2525
println!("cargo::rerun-if-changed=src/apf_fuzz.cpp");
2626

27+
emit_shorthands();
28+
2729
// NOTE(eddyb) `rustc_apfloat`'s own `build.rs` validated the version string.
2830
let (_, llvm_commit_hash) = env!("CARGO_PKG_VERSION").split_once("+llvm-").unwrap();
2931
assert_eq!(llvm_commit_hash.len(), 12);
@@ -143,3 +145,19 @@ fn main() -> io::Result<()> {
143145

144146
Ok(())
145147
}
148+
149+
/// Convenient versions of repeated configuration.
150+
fn emit_shorthands() {
151+
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
152+
let target_features = env::var("CARGO_CFG_TARGET_FEATURE")
153+
.map(|feats| feats.split(',').map(ToOwned::to_owned).collect::<Vec<_>>())
154+
.unwrap_or_default();
155+
156+
// Emit a config
157+
println!("cargo::rustc-check-cfg=cfg(x86_sse2)");
158+
if (target_arch == "x86_64" || target_arch == "x86")
159+
&& target_features.iter().any(|feat| feat == "sse2")
160+
{
161+
println!("cargo::rustc-cfg=x86_sse2");
162+
}
163+
}

0 commit comments

Comments
 (0)