Commit 87db567e1f094cbc9118f7c8d215df157b1601b5
Committed by
Jay Berkenbilt
1 parent
5ee21c67
Convert oss-fuzz-build to use cmake
Showing
3 changed files
with
14 additions
and
19 deletions
README-maintainer
| ... | ... | @@ -80,11 +80,8 @@ GOOGLE OSS-FUZZ |
| 80 | 80 | |
| 81 | 81 | Clone the oss-fuzz project. From the root directory of the repository: |
| 82 | 82 | |
| 83 | - Add `-e GITHUB_FORK=fork -e GITHUB_BRANCH=branch` to build_fuzzers | |
| 84 | - from a qpdf fork/branch rather than qpdf/main. | |
| 85 | - | |
| 86 | 83 | python3 infra/helper.py build_image --pull qpdf |
| 87 | - python3 infra/helper.py build_fuzzers [ --sanitizer memory|undefined|address ] qpdf | |
| 84 | + python3 infra/helper.py build_fuzzers [ --sanitizer memory|undefined|address ] qpdf [path-to-qpdf-source] | |
| 88 | 85 | python3 infra/helper.py check_build qpdf |
| 89 | 86 | python3 infra/helper.py build_fuzzers --sanitizer coverage qpdf |
| 90 | 87 | python3 infra/helper.py coverage qpdf | ... | ... |
build-scripts/build-fuzzer
| ... | ... | @@ -4,8 +4,12 @@ export WORK=$PWD/work |
| 4 | 4 | export OUT=$PWD/out |
| 5 | 5 | mkdir -p $WORK $OUT |
| 6 | 6 | sudo apt-get update |
| 7 | -sudo apt-get -y install \ | |
| 8 | - autoconf build-essential zlib1g-dev libjpeg-dev | |
| 7 | +sudo apt-get -y install build-essential cmake zlib1g-dev libjpeg-dev | |
| 9 | 8 | ./fuzz/oss-fuzz-build |
| 10 | -ls -l out/qpdf*fuzzer | |
| 9 | +ls -l out/qpdf_fuzzer | |
| 11 | 10 | ls -l out/ |
| 11 | +if ldd out/qpdf_fuzzer | egrep 'libjpeg|libz|libqpdf'; then | |
| 12 | + echo 1>&2 "*** Fuzzers linked dynamically with some dependent libraries." | |
| 13 | + ldd out/qpdf_fuzzer | |
| 14 | + exit 2 | |
| 15 | +fi | ... | ... |
fuzz/oss-fuzz-build
| ... | ... | @@ -21,15 +21,9 @@ if [[ $GITHUB_FORK != "" ]]; then |
| 21 | 21 | fi |
| 22 | 22 | fi |
| 23 | 23 | |
| 24 | -./configure \ | |
| 25 | - --enable-oss-fuzz \ | |
| 26 | - --enable-static \ | |
| 27 | - --disable-shared \ | |
| 28 | - --enable-crypto-native \ | |
| 29 | - --disable-implicit-crypto \ | |
| 30 | - --prefix="$WORK" \ | |
| 31 | - LDFLAGS="-L$WORK/lib" \ | |
| 32 | - CPPFLAGS="-I$WORK/include" \ | |
| 33 | - LIBS="-pthread" | |
| 34 | -make -j$(nproc) install | |
| 35 | -make install_fuzz | |
| 24 | +env CMAKE_PREFIX_PATH=$WORK LDFLAGS="-L$WORK/lib -lpthread" \ | |
| 25 | + cmake -S . -B build \ | |
| 26 | + -DOSS_FUZZ=1 -DBUILD_SHARED_LIBS=0 -DCMAKE_BUILD_TYPE=Debug \ | |
| 27 | + -DUSE_IMPLICIT_CRYPTO=0 -DREQUIRE_CRYPTO_NATIVE=1 | |
| 28 | +cmake --build build -j$(nproc) --target fuzzers | |
| 29 | +cmake --install build --component fuzz | ... | ... |