[infra] renaming LDFLAGS into FUZZER_LDFLAGS. Fixes #31

This commit is contained in:
Mike Aizatsky 2016-10-13 14:19:30 -07:00
parent a18ac2542e
commit 941e47d6e1
20 changed files with 26 additions and 32 deletions

View File

@ -23,7 +23,7 @@ CXXFLAGS="$CXXFLAGS -DBORINGSSL_UNSAFE_FUZZER_MODE"
cmake -GNinja -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX \
-DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$FUZZER_LDFLAGS" \
/src/boringssl/
ninja
@ -34,7 +34,7 @@ find . -name "*.a"
for F in $fuzzerFiles; do
fuzzerName=$(basename $F .cc)
echo "Building fuzzer $fuzzerName"
$CXX $CXXFLAGS $LDFLAGS -std=c++11 \
$CXX $CXXFLAGS $FUZZER_LDFLAGS -std=c++11 \
-o /out/openssl_${fuzzerName} /work/libfuzzer/*.o $F \
-I /src/boringssl/include ./ssl/libssl.a ./crypto/libcrypto.a
done

View File

@ -19,4 +19,4 @@ cd /src/curl
./buildconf
./configure --disable-shared --enable-debug --enable-maintainer-mode --disable-symbol-hiding --disable-threaded-resolver --enable-ipv6 --with-random=/dev/null
make -j4
$CXX $CXXFLAGS /src/fuzzer.cc -Iinclude lib/.libs/libcurl.a -lssl -lcrypto -lz /work/libfuzzer/*.o -o /out/curl_fuzzer $LDFLAGS
$CXX $CXXFLAGS /src/fuzzer.cc -Iinclude lib/.libs/libcurl.a -lssl -lcrypto -lz /work/libfuzzer/*.o -o /out/curl_fuzzer $FUZZER_LDFLAGS

View File

@ -104,7 +104,7 @@ make clean all
$CXX $CXXFLAGS -std=c++11 -Ilib/ \
/src/oss-fuzz/expat/parse_fuzzer.cc -o /out/expat_parse_fuzzer \
/work/libfuzzer/*.o .libs/libexpat.a \
$LDFLAGS
$FUZZER_LDFLAGS
```
### build.sh Script Environment
@ -120,13 +120,11 @@ When build.sh script is executed, the following locations are available within t
You *must* use special compiler flags to build your library and fuzzers.
These flags are provided in following environment variables:
| Env Variable | Description
| ------------- | --------
| `$CC` | The C compiler binary.
| `$CXX`, `$CCC` | The C++ compiler binary.
| `$CFLAGS` | C compiler flags.
| `$CXXFLAGS` | C++ compiler flags.
| `$LDFLAGS` | Linker flags for fuzzer binaries.
| Env Variable | Description
| ------------- | --------
| `$CC`, `$CXX`, `$CCC` | The C and C++ compiler binaries.
| `$CFLAGS`, `$CXXFLAGS` | C and C++ compiler flags.
| `$FUZZER_LDFLAGS` | Linker flags for fuzzer binaries.
Many well-crafted build scripts will automatically use these variables. If not,
passing them manually to a build tool might be required.

View File

@ -7,6 +7,6 @@ make clean all
$CXX $CXXFLAGS -std=c++11 -Ilib/ \
/src/parse_fuzzer.cc -o /out/expat_parse_fuzzer \
/work/libfuzzer/*.o .libs/libexpat.a $LDFLAGS
/work/libfuzzer/*.o .libs/libexpat.a $FUZZER_LDFLAGS
cp /src/*.dict /src/*.options /out/

View File

@ -21,7 +21,7 @@ cd /src/freetype2/
./configure
make clean all
$CXX $CXXFLAGS $LDFLAGS -std=c++11 \
$CXX $CXXFLAGS $FUZZER_LDFLAGS -std=c++11 \
-I./include -I. \
./src/tools/ftfuzzer/ftfuzzer.cc -o /out/freetype2_fuzzer \
./objs/*.o /work/libfuzzer/*.o \

View File

@ -24,4 +24,4 @@ make clean all
$CXX $CXXFLAGS -std=c++11 -Isrc \
/src/harfbuzz_fuzzer.cc -o /out/harfbuzz_fuzzer \
/work/libfuzzer/*.o src/.libs/*.o src/hb-ucdn/.libs/*.o $LDFLAGS
/work/libfuzzer/*.o src/.libs/*.o src/hb-ucdn/.libs/*.o $FUZZER_LDFLAGS

View File

@ -24,7 +24,7 @@ ENV SANITIZER_FLAGS="-fsanitize=address"
ENV COV_FLAGS="-fsanitize-coverage=edge,indirect-calls,8bit-counters"
ENV ASAN_OPTIONS="symbolize=1:detect_leaks=0"
ENV LDFLAGS "-Wl,-whole-archive /usr/local/lib/libc++.a /usr/local/lib/libc++abi.a -Wl,-no-whole-archive"
ENV FUZZER_LDFLAGS "-Wl,-whole-archive /usr/local/lib/libc++.a /usr/local/lib/libc++abi.a -Wl,-no-whole-archive"
RUN mkdir /out

View File

@ -31,7 +31,7 @@ These flags are provided in following environment variables:
| `$CXX`, `$CCC` | The C++ compiler binary.
| `$CFLAGS` | C compiler flags.
| `$CXXFLAGS` | C++ compiler flags.
| `$LDFLAGS` | Linker flags for fuzzer binaries.
| `$FUZZER_LDFLAGS` | Linker flags for fuzzer binaries.
Many well-crafted build scripts will automatically use these variables. If not,
passing them manually to a build tool might be required.

View File

@ -32,7 +32,7 @@ echo "CC=$CC"
echo "CXX=$CXX"
echo "CFLAGS=$CFLAGS"
echo "CXXFLAGS=$CXXFLAGS"
echo "LDFLAGS=$LDFLAGS"
echo "FUZZER_LDFLAGS=$FUZZER_LDFLAGS"
echo "---------------------------------------------------------------"

View File

@ -19,6 +19,6 @@ cd /src/json
$CXX $CXXFLAGS -std=c++11 -I/src/json/src/ \
/src/parse_fuzzer.cc -o /out/parse_fuzzer \
/work/libfuzzer/*.o $LDFLAGS
/work/libfuzzer/*.o $FUZZER_LDFLAGS
cp /src/*.options /out/

View File

@ -29,7 +29,7 @@ $CC $CFLAGS \
-o /out/chewing_fuzzer \
/src/chewing_fuzzer.c \
test/stress.o test/.libs/libtesthelper.a src/.libs/libchewing.a \
/work/libfuzzer/*.o $LDFLAGS
/work/libfuzzer/*.o $FUZZER_LDFLAGS
# install data files
make -C data pkgdatadir=/out install

View File

@ -30,6 +30,6 @@ make clean all
# build libpng_read_fuzzer
$CXX $CXXFLAGS -std=c++11 -I. -lz \
/src/libpng_read_fuzzer.cc -o /out/libpng_read_fuzzer \
/work/libfuzzer/*.o .libs/libpng16.a $LDFLAGS
/work/libfuzzer/*.o .libs/libpng16.a $FUZZER_LDFLAGS
cp /src/*.dict /src/*.options /out/

View File

@ -24,7 +24,7 @@ make clean all
for fuzzer in libxml2_xml_read_memory_fuzzer libxml2_xml_regexp_compile_fuzzer; do
$CXX $CXXFLAGS -std=c++11 -Iinclude/ \
/src/$fuzzer.cc -o /out/$fuzzer \
/work/libfuzzer/*.o .libs/libxml2.a $LDFLAGS
/work/libfuzzer/*.o .libs/libxml2.a $FUZZER_LDFLAGS
done
cp /src/*.dict /src/*.options /out/

View File

@ -62,5 +62,5 @@ for fuzzer in $FUZZERS; do
/work/libfuzzer/*.o \
/work/nss/lib/libnss.a /work/nss/lib/libnssutil.a \
/work/nss/lib/libnspr4.a /work/nss/lib/libplc4.a /work/nss/lib/libplds4.a \
/work/nss/lib/prlog2.o -o /out/$fuzzer $LDFLAGS
/work/nss/lib/prlog2.o -o /out/$fuzzer $FUZZER_LDFLAGS
done

View File

@ -21,13 +21,11 @@ cd pcre2
# build the library.
./autogen.sh
SAVED_LDFLAGS="$LDFLAGS"
export LDFLAGS= # Can't use provided LDFLAGS to build pcre's .a targets.
./configure --enable-never-backslash-C --with-match-limit=1000 --with-match-limit-recursion=1000
make clean all
# Build the target.
$CXX $CXXFLAGS -std=c++11 -I src \
/src/pcre2_fuzzer.cc -o /out/pcre2_fuzzer \
-Wl,--whole-archive .libs/*.a -Wl,-no-whole-archive $SAVED_LDFLAGS \
-Wl,--whole-archive .libs/*.a -Wl,-no-whole-archive $FUZZER_LDFLAGS \
/work/libfuzzer/*.o

View File

@ -32,6 +32,6 @@ make obj/libre2.a
# Second, build our fuzzers.
$CXX $CXXFLAGS -std=c++11 -I. \
/src/re2_fuzzer.cc -o /out/re2_fuzzer \
/work/libfuzzer/*.o ./obj/libre2.a $LDFLAGS
/work/libfuzzer/*.o ./obj/libre2.a $FUZZER_LDFLAGS
cp /src/*.options /out/

View File

@ -94,5 +94,5 @@ cd /src/%s
# e.g.
# $CXX $CXXFLAGS -std=c++11 -Iinclude \\
# /path/to/name_of_fuzzer.cc -o /out/name_of_fuzzer \\
# /work/libfuzzer/*.o /path/to/library.a $LDFLAGS
# /work/libfuzzer/*.o /path/to/library.a $FUZZER_LDFLAGS
"""

View File

@ -34,6 +34,6 @@ make sqlite3.c
$CXX $CXXFLAGS -std=c++11 -I. \
/src/sqlite3_fuzzer.cc -o /out/sqlite3_fuzzer \
/work/libfuzzer/*.o ./sqlite3.o $LDFLAGS
/work/libfuzzer/*.o ./sqlite3.o $FUZZER_LDFLAGS
cp /src/*.options /src/*.dict /out/

View File

@ -31,8 +31,6 @@ cat Makefile | sed -e "s/-no-canonical-prefixes//" \
> Makefile.temp
mv Makefile.temp Makefile
# woff2 uses LFLAGS instead of LDFLAGS.
export LFLAGS=$LDFLAGS
make CC="$CC $CFLAGS" CXX="$CXX $CXXFLAGS" clean all
# To avoid multiple main() definitions.
@ -42,6 +40,6 @@ rm src/woff2_compress.o src/woff2_decompress.o
fuzzer=convert_woff2ttf_fuzzer
$CXX $CXXFLAGS -std=c++11 -Isrc \
/src/$fuzzer.cc -o /out/$fuzzer \
/work/libfuzzer/*.o src/*.o brotli/dec/*.o brotli/enc/*.o $LDFLAGS
/work/libfuzzer/*.o src/*.o brotli/dec/*.o brotli/enc/*.o $FUZZER_LDFLAGS
cp /src/*.options /out/

View File

@ -7,4 +7,4 @@ make clean all
$CXX $CXXFLAGS -std=c++11 -I. \
/src/zlib_uncompress_fuzzer.cc -o /out/zlib_uncompress_fuzzer \
/work/libfuzzer/*.o ./libz.a $LDFLAGS
/work/libfuzzer/*.o ./libz.a $FUZZER_LDFLAGS