aboutsummaryrefslogtreecommitdiffhomepage
path: root/projects/gnutls/build.sh
diff options
context:
space:
mode:
authorGravatar Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>2017-08-16 17:09:27 +0200
committerGravatar Oliver Chang <oliverchang@users.noreply.github.com>2017-08-16 08:09:27 -0700
commitc021b7dc0ce54b491d08bb911a4ebe81aad334ab (patch)
tree7044881ff7d888fd996bff5396de205c8932f5d6 /projects/gnutls/build.sh
parentaa80ddcc86948edc13015095d1a92b5e972b160e (diff)
New fuzzing architecture (#779)
Requisites are build as static libraries and as these linked to the fuzzers. p11-kit can't be build statically, thus our fuzzers are not using it.
Diffstat (limited to 'projects/gnutls/build.sh')
-rwxr-xr-xprojects/gnutls/build.sh98
1 files changed, 66 insertions, 32 deletions
diff --git a/projects/gnutls/build.sh b/projects/gnutls/build.sh
index bd4c6360..50f9b977 100755
--- a/projects/gnutls/build.sh
+++ b/projects/gnutls/build.sh
@@ -15,49 +15,83 @@
#
################################################################################
-CONFIGURE_FLAGS=""
-NETTLE_CONFIGURE_FLAGS=""
-if [[ $CFLAGS = *sanitize=memory* ]]
-then
- CONFIGURE_FLAGS="--disable-hardware-acceleration"
- NETTLE_CONFIGURE_FLAGS="--disable-assembler --disable-fat"
+export DEPS_PATH=$SRC/deps
+export PKG_CONFIG_PATH=$DEPS_PATH/lib/pkgconfig
+export CPPFLAGS="-I$DEPS_PATH/include"
+export LDFLAGS="-L$DEPS_PATH/lib"
+export GNULIB_SRCDIR=$SRC/gnulib
+
+cd $SRC/libunistring
+./autogen.sh
+ASAN_OPTIONS=detect_leaks=0 \
+ ./configure --enable-static --disable-shared --prefix=$DEPS_PATH
+make -j$(nproc)
+make install
+
+cd $SRC/libidn2
+./bootstrap
+ASAN_OPTIONS=detect_leaks=0 \
+ ./configure --enable-static --disable-shared --disable-doc --disable-gcc-warnings --prefix=$DEPS_PATH
+make -j$(nproc)
+make install
+
+GMP_CONFIGURE_FLAGS=""
+if [[ $CFLAGS = *sanitize=memory* ]]; then
+ GMP_CONFIGURE_FLAGS="--disable-assembly --disable-fat"
fi
+cd $SRC/gmp
+bash .bootstrap
+ASAN_OPTIONS=detect_leaks=0 \
+ ./configure --disable-shared --prefix=$DEPS_PATH
+make -j$(nproc)
+make install
-# We could use GMP from git repository to avoid false positives in
-# sanitizers, but GMP doesn't compile with clang. We use gmp-mini
-# instead.
+cd $SRC/libtasn1
+CFGFLAGS="--disable-gcc-warnings --disable-gtk-doc --disable-gtk-doc-pdf --disable-doc \
+ --disable-shared --enable-static --prefix=$DEPS_PATH" \
+ make bootstrap
+make -j$(nproc)
+make install
-pushd nettle
+NETTLE_CONFIGURE_FLAGS=""
+if [[ $CFLAGS = *sanitize=memory* ]]; then
+ NETTLE_CONFIGURE_FLAGS="--disable-assembler --disable-fat"
+fi
+cd $SRC/nettle
bash .bootstrap
-./configure --enable-mini-gmp --disable-documentation --libdir=/opt/lib/ --prefix=/opt $NETTLE_CONFIGURE_FLAGS && ( make -j$(nproc) || make -j$(nproc) ) && make install
-if test $? != 0;then
- echo "Failed to compile nettle"
- exit 1
+ASAN_OPTIONS=detect_leaks=0 \
+ ./configure --enable-static --disable-shared --disable-documentation --prefix=$DEPS_PATH $NETTLE_CONFIGURE_FLAGS
+( make -j$(nproc) || make -j$(nproc) ) && make install
+if test $? != 0; then
+ echo "Failed to compile nettle"
+ exit 1
fi
-popd
-make bootstrap
-PKG_CONFIG_PATH=/opt/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig ./configure --with-nettle-mini --enable-gcc-warnings --enable-static --with-included-libtasn1 \
- --with-included-unistring --without-p11-kit --disable-doc $CONFIGURE_FLAGS
+
+GNUTLS_CONFIGURE_FLAGS=""
+if [[ $CFLAGS = *sanitize=memory* ]]; then
+ GNUTLS_CONFIGURE_FLAGS="--disable-hardware-acceleration"
+fi
+cd $SRC/gnutls
+make autoreconf
+ASAN_OPTIONS=detect_leaks=0 LIBS="-lunistring" CXXFLAGS="$CXXFLAGS -L$DEPS_PATH/lib" \
+ ./configure --disable-gcc-warnings --enable-static --disable-shared --disable-doc --disable-tests \
+ --disable-tools --disable-cxx --disable-maintainer-mode --disable-libdane --without-p11-kit $GNUTLS_CONFIGURE_FLAGS
# Do not use the syscall interface for randomness in oss-fuzz, it seems
# to confuse memory sanitizer.
sed -i 's|include <sys/syscall.h>|include <sys/syscall.h>\n#undef SYS_getrandom|' lib/nettle/sysrng-linux.c
-make "-j$(nproc)" -C gl
-make "-j$(nproc)" -C lib
-
-fuzzers=$(find devel/fuzz/ -name "*_fuzzer.cc")
+make -j$(nproc) -C gl
+make -j$(nproc) -C lib
-for f in $fuzzers; do
- fuzzer=$(basename "$f" ".cc")
- $CXX $CXXFLAGS -std=c++11 -Ilib/includes \
- "devel/fuzz/${fuzzer}.cc" -o "$OUT/${fuzzer}" \
- lib/.libs/libgnutls.a -lFuzzingEngine -lpthread -Wl,-Bstatic \
- /opt/lib/libhogweed.a /opt/lib/libnettle.a -Wl,-Bdynamic
+cd fuzz
+make oss-fuzz
+find . -name '*_fuzzer' -exec cp -v '{}' $OUT ';'
+find . -name '*_fuzzer.dict' -exec cp -v '{}' $OUT ';'
+find . -name '*_fuzzer.options' -exec cp -v '{}' $OUT ';'
- corpus_dir=$(basename "${fuzzer}" "_fuzzer")
- if [ -d "devel/fuzz/${corpus_dir}.in/" ]; then
- zip -r "$OUT/${fuzzer}_seed_corpus.zip" "devel/fuzz/${corpus_dir}.in/"
- fi
+for dir in *_fuzzer.in; do
+ fuzzer=$(basename $dir .in)
+ zip -rj "$OUT/${fuzzer}_seed_corpus.zip" "${dir}/"
done