3 # This is not a general-purpose build script, but instead one specific to the Google oss-fuzz compile environment.
5 # https://google.github.io/oss-fuzz/getting-started/new-project-guide/#Requirements
7 # https://github.com/google/oss-fuzz/blob/master/infra/base-images/base-builder/README.md#provided-environment-variables
9 # We have to push to oss-fuzz CFLAGS into the waf ADDITIONAL_CFLAGS
10 # as otherwise waf's configure fails linking the first test binary
12 # CFLAGS are supplied by the caller, eg the oss-fuzz compile command
14 # Additional arguments are passed to configure, to allow this to be
15 # tested in autobuild.py
17 ADDITIONAL_CFLAGS="$CFLAGS"
18 export ADDITIONAL_CFLAGS
24 # $SANITIZER is provided by the oss-fuzz "compile" command
26 # We need to add the waf configure option as otherwise when we also
27 # get (eg) -fsanitize=address via the CFLAGS we will fail to link
32 SANITIZER_ARG='--address-sanitizer'
35 SANITIZER_ARG='--undefined-sanitizer'
39 # $LIB_FUZZING_ENGINE is provided by the oss-fuzz "compile" command
42 ./configure -C --without-gettext --enable-debug --enable-developer \
45 --disable-warnings-as-errors \
47 --fuzz-target-ldflags="$LIB_FUZZING_ENGINE" \
48 --nonshared-binary=ALL \
54 # Make a directory for the system shared libraries to be copied into
57 # We can't static link to all the system libs with waf, so copy them
58 # to $OUT/lib and set the rpath to point there. This is similar to how
59 # firefox handles this.
66 # Copy any system libraries needed by this fuzzer to $OUT/lib
67 ldd $OUT/$bin | cut -f 2 -d '>' | cut -f 1 -d \( | cut -f 2 -d ' ' | xargs -i cp \{\} $OUT/lib/
69 # Change RUNPATH so that the copied libraries are found on the
71 chrpath -r '$ORIGIN/lib' $OUT/$bin
73 # Truncate the original binary to save space