Add a new CI builder that builds fuzz targets#5352
Open
graydon wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a dedicated CI job intended to build fully executable, libFuzzer-instrumented fuzz targets (matching the OSS-Fuzz build configuration) to ensure the OSS-Fuzz build remains healthy.
Changes:
- Replaces
build-fuzz.shwith an OSS-Fuzz-aligned build script that performs an out-of-tree build inbuild-clang-libfuzzer/and copies builtfuzz_*binaries to$OUT. - Adds a new GitHub Actions job
build-linux-fuzz-targetsand wires it into thecompletejob dependency list.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
build-fuzz.sh |
Updated to build fuzz targets in an OSS-Fuzz-like configuration (ccache, unified rust build, fuzz target build + copy to $OUT). |
.github/workflows/build.yml |
Adds a new Linux CI builder job to run the fuzz-target build script and cache relevant build directories. |
Comment on lines
+12
to
+15
| SRC_DIR=$(pwd) | ||
| mkdir -p "build-clang-libfuzzer" | ||
| cd "build-clang-libfuzzer" | ||
|
|
Comment on lines
+26
to
+31
| if [ -d "$CCACHE_DIR" ] ; then | ||
| if [ -n "$(find $CCACHE_DIR -mtime +$CACHE_MAX_DAYS -print -quit)" ] ; then | ||
| echo Purging old cache dirs $CCACHE_DIR ./target $HOME/.cargo/registry $HOME/.cargo/git | ||
| rm -rf $CCACHE_DIR ./target $HOME/.cargo/registry $HOME/.cargo/git | ||
| fi | ||
| done | ||
|
|
||
| # Generate and package seed corpus (if stellar-core supports it) | ||
| # For now, create empty corpus directories | ||
| mkdir -p corpus/tx corpus/overlay corpus/soroban_expr corpus/soroban_wasmi | ||
|
|
||
| # Create corpus archives (even if empty, oss-fuzz expects them) | ||
| # Create corpus archives for all targets (even if empty, oss-fuzz expects them) | ||
| for target in tx overlay soroban_expr soroban_wasmi; do | ||
| if [ -d "corpus/$target" ] && [ "$(ls -A "corpus/$target" 2>/dev/null)" ]; then | ||
| (cd "corpus/$target" && zip -q "$OUT/fuzz_${target}_seed_corpus.zip" *) | ||
| else | ||
| # Create empty zip if no corpus | ||
| touch empty && zip -q "$OUT/fuzz_${target}_seed_corpus.zip" empty && rm empty | ||
| fi | ||
| done | ||
| fi |
| "${SRC_DIR}/configure" --enable-fuzz --enable-unified-rust-unsafe-for-production --disable-postgres --enable-ccache | ||
| make -j $(nproc) | ||
| make -C src fuzz-targets | ||
| cp src/fuzz_* $OUT |
Comment on lines
+265
to
+276
| - name: Build fuzz targets | ||
| if: steps.check-last-tested-commit.outputs.skip != 'true' | ||
| run: | ||
| export CC=clang | ||
| export CXX=clang++ | ||
| export CFLAGS="-g -fsanitize=fuzzer-no-link,address" | ||
| export CXXFLAGS="-g -fsanitize=fuzzer-no-link,address" | ||
| export LIB_FUZZING_ENGINE="-fsanitize=fuzzer" | ||
| export OUT=./fuzz-out | ||
| rm -rf fuzz-out | ||
| mkdir fuzz-out | ||
| ./build-fuzzers.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a new CI builder that builds with the configuration necessary to build the fully-executable fuzz targets -- not just the fuzz-target logic (which is already built and smoke-tested as part of the unit test suite) -- but the actual instrumented-for-greybox-fuzzing build, with unified-build mode, linked against a fuzz driver and ready to run.
This is the configuration that OSS-fuzz runs, and it runs a build script that's lightly adapted from the build script OSS-fuzz runs. This is intended to "keep the OSS-fuzz build building".