build.sh 1.2 KB

12345678910111213141516171819202122232425262728
  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. # The OSS-Fuzz base image exports CXX=clang++ with a CXXFLAGS that selects
  9. # libc++ (-stdlib=libc++). libfuzzer-sys's build script compiles libFuzzer's
  10. # C++ runtime with those flags, but rustc/cc links the C++ stdlib as libstdc++
  11. # (-lstdc++), so the runtime's libc++ (std::__1::) symbols end up undefined at
  12. # link time. clang++ defaults to libstdc++ when the flag is absent, so drop it
  13. # to make the compiled runtime and the link line agree.
  14. CXXFLAGS="${CXXFLAGS:-}"
  15. export CXXFLAGS="${CXXFLAGS//-stdlib=libc++/}"
  16. cargo fuzz build -O --debug-assertions
  17. for target_path in fuzz_targets/*.rs; do
  18. target="$(basename "$target_path" .rs)"
  19. cp "build/x86_64-unknown-linux-gnu/release/$target" "$OUT/" 2>/dev/null \
  20. || cp "target/x86_64-unknown-linux-gnu/release/$target" "$OUT/"
  21. if [ -d "corpus/$target" ]; then
  22. zip -j "$OUT/${target}_seed_corpus.zip" "corpus/$target/"* 2>/dev/null || true
  23. fi
  24. done