Skip to content

Add a new CI builder that builds fuzz targets#5352

Open
graydon wants to merge 1 commit into
stellar:masterfrom
graydon:build-fuzzers-in-ci
Open

Add a new CI builder that builds fuzz targets#5352
graydon wants to merge 1 commit into
stellar:masterfrom
graydon:build-fuzzers-in-ci

Conversation

@graydon

@graydon graydon commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

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".

Copilot AI review requested due to automatic review settings July 15, 2026 17:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.sh with an OSS-Fuzz-aligned build script that performs an out-of-tree build in build-clang-libfuzzer/ and copies built fuzz_* binaries to $OUT.
  • Adds a new GitHub Actions job build-linux-fuzz-targets and wires it into the complete job 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 thread build-fuzz.sh
Comment on lines +12 to +15
SRC_DIR=$(pwd)
mkdir -p "build-clang-libfuzzer"
cd "build-clang-libfuzzer"

Comment thread build-fuzz.sh
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
Comment thread build-fuzz.sh
"${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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants