build.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash -eu
  2. # ClusterFuzzLite build script (T4-3): compile every cargo-fuzz target and
  3. # stage the binaries plus any checked-in seed corpus into $OUT.
  4. #
  5. # Hermetic by construction: every target exercises only pure parsers (no
  6. # network, Postgres, or Redis), so the OSS-Fuzz sandbox needs no services.
  7. cd "$SRC/d-oauth-server/fuzz"
  8. # Drop the OSS-Fuzz sanitizer C flags. The base image prepends
  9. # `-fsanitize=address ...` to CFLAGS/CXXFLAGS; the `cc`-compiled C/asm in a
  10. # dependency (ring, pulled by sqlx's `tls-rustls-ring-webpki` feature) then
  11. # carries ASan instrumentation. Those objects reach the *host* proc-macro
  12. # `sqlx-macros` through its dependency graph, and because rustc does not link
  13. # the ASan runtime into a proc-macro cdylib, that `.so` ends up with undefined
  14. # `__asan_*`/`__sancov_lowest_stack` symbols and rustc cannot dlopen it while
  15. # compiling `sqlx` (the scheduled `cflite-batch` failure). Dropping CXXFLAGS
  16. # also lets clang++ default to libstdc++: the image's `-stdlib=libc++` would
  17. # otherwise leave libFuzzer's C++ runtime (`std::__1::`) symbols undefined at
  18. # link time. The Rust code keeps full ASan + libFuzzer coverage -- `cargo fuzz`
  19. # supplies those Rust flags itself (the same scoped-flag mechanism `ci.yml
  20. # fuzz-build` relies on, and it runs with no sanitizer env) -- and the C parts
  21. # (libFuzzer runtime, ring) need no instrumentation for these pure-parser
  22. # targets.
  23. unset CFLAGS CXXFLAGS RUSTFLAGS
  24. cargo fuzz build -O --debug-assertions
  25. for target_path in fuzz_targets/*.rs; do
  26. target="$(basename "$target_path" .rs)"
  27. cp "build/x86_64-unknown-linux-gnu/release/$target" "$OUT/" 2>/dev/null \
  28. || cp "target/x86_64-unknown-linux-gnu/release/$target" "$OUT/"
  29. if [ -d "corpus/$target" ]; then
  30. zip -j "$OUT/${target}_seed_corpus.zip" "corpus/$target/"* 2>/dev/null || true
  31. fi
  32. done