Skip to content

Commit 82c787d

Browse files
committed
fuzz: Use the 2024 edition
Make it possible for us to use `let` chains.
1 parent 595224f commit 82c787d

3 files changed

Lines changed: 11 additions & 23 deletions

File tree

fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_apfloat-fuzz"
33
version.workspace = true
4-
edition.workspace = true
4+
edition = "2024"
55
publish = false
66

77
[dependencies]

fuzz/build.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,6 @@ fn main() -> io::Result<()> {
4949
)
5050
}
5151

52-
// HACK(eddyb) work around https://github.com/rust-lang/cargo/issues/3676,
53-
// by removing the env vars that Cargo appears to hardcode.
54-
const CARGO_HARDCODED_ENV_VARS: &[(&str, &str)] = &[
55-
("SSL_CERT_DIR", "/etc/pki/tls/certs"),
56-
("SSL_CERT_FILE", "/etc/pki/tls/certs/ca-bundle.crt"),
57-
];
58-
for &(var_name, cargo_hardcoded_value) in CARGO_HARDCODED_ENV_VARS {
59-
if let Ok(value) = env::var(var_name) {
60-
if value == cargo_hardcoded_value {
61-
env::remove_var(var_name);
62-
}
63-
}
64-
}
65-
6652
let llvm_dir = llvm_root.join("llvm");
6753
let bc_out = out_dir.join("cxx_apf_fuzz.bc");
6854
let bc_opt_out = out_dir.join("cxx_apf_fuzz.opt.bc");
@@ -72,6 +58,9 @@ fn main() -> io::Result<()> {
7258
// Flags could probably be split between the frontend and backend.
7359
let clang_codegen_flags = ["-g", "-fPIC", "-fno-exceptions", "-O3", "-march=native"];
7460

61+
// Note that all commands clear the environment to work around
62+
// https://github.com/rust-lang/cargo/issues/3676.
63+
7564
// HACK(eddyb) first compile all the source files into one `.bc` file:
7665
// - "unity build" (w/ `--include`) lets `-o` specify path (no `--out-dir` sadly)
7766
// - LLVM `.bc` intermediate allows the steps below to reduce dependencies

fuzz/src/main.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ macro_rules! float_reprs {
167167

168168
// FIXME: we are discarding status results here and not making use of rounding mode.
169169
fn cxx_apf_eval_fuzz_op(op: FuzzOp<Self>) -> Self {
170-
extern "C" {
171-
fn $cxx_apf_eval_fuzz_op(
170+
// SAFETY: matches definition in `ap_fuzz.cpp`
171+
unsafe extern "C" {
172+
safe fn $cxx_apf_eval_fuzz_op(
172173
opcode: u8,
173174
round: u8,
174175
ai: $repr,
@@ -192,11 +193,7 @@ macro_rules! float_reprs {
192193
};
193194

194195
let mut out = 0;
195-
196-
let _status = unsafe {
197-
$cxx_apf_eval_fuzz_op(op.tag(), 0, ai, bi, ci, &mut out)
198-
};
199-
196+
let _status = $cxx_apf_eval_fuzz_op(op.tag(), 0, ai, bi, ci, &mut out);
200197
Self(out)
201198
}
202199

@@ -885,6 +882,8 @@ fn main() {
885882
// of basic examples, e.g. every `FuzzOp` variant with `0.0` for all inputs
886883
// (and/or maybe testcases from known and/or fixed bugs, too).
887884
eprintln!(" - seed with `mkdir fuzz/in-foo && echo > fuzz/in-foo/empty`");
888-
eprintln!(" - run with `cargo afl fuzz -i fuzz/in-foo -o fuzz/out-foo target/release/rustc_apfloat-fuzz`");
885+
eprintln!(
886+
" - run with `cargo afl fuzz -i fuzz/in-foo -o fuzz/out-foo target/release/rustc_apfloat-fuzz`"
887+
);
889888
std::process::exit(1);
890889
}

0 commit comments

Comments
 (0)