global-state-detector 0.1.0

Detect persistent writable global state between fuzzer iterations (Rust bindings for the global-state-detector C library)
Documentation
// Compiles the upstream global_state_detector C library (vendored as a
// submodule under `csrc/`) into the crate.
//
// Link-arg notes:
//   * `-rdynamic` keeps symbols in the dynamic symbol table so dladdr()
//     can resolve names in the main executable when reporting changes.
//   * `-Wl,-z,now` disables lazy PLT/GOT binding so the first iteration
//     does not look like writable global state churn.
//
// IMPORTANT: cargo does NOT propagate `rustc-link-arg` from rlib
// dependencies to downstream binaries. Consumers (e.g. cargo-fuzz
// targets) must add the same flags in their own build, e.g. via
// `.cargo/config.toml`:
//
//   [target.'cfg(target_os = "linux")']
//   rustflags = ["-C", "link-arg=-rdynamic", "-C", "link-arg=-Wl,-z,now"]
//
// The flags emitted here only cover binaries built inside this package
// (tests, examples, benches).

fn main() {
    cc::Build::new()
        .file("csrc/global_state_detector.c")
        .flag("-O2")
        .flag("-g")
        .compile("global_state_detector");

    println!("cargo:rustc-link-lib=dylib=dl");
    println!("cargo:rustc-link-arg=-rdynamic");
    println!("cargo:rustc-link-arg=-Wl,-z,now");
    println!("cargo:rerun-if-changed=csrc/global_state_detector.c");
    println!("cargo:rerun-if-changed=csrc/global_state_detector.h");
}