• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2# Copyright 2016 Google Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16################################################################################
17
18export WGET_DEPS_PATH=$SRC/wget_deps
19export PKG_CONFIG_PATH=$WGET_DEPS_PATH/lib64/pkgconfig:$WGET_DEPS_PATH/lib/pkgconfig
20export CPPFLAGS="-I$WGET_DEPS_PATH/include"
21export LDFLAGS="-L$WGET_DEPS_PATH/lib"
22export GNULIB_SRCDIR=$SRC/gnulib
23export LLVM_PROFILE_FILE=/tmp/prof.test
24
25cd $SRC/libunistring
26./autogen.sh
27./configure --enable-static --disable-shared --prefix=$WGET_DEPS_PATH --cache-file ../config.cache
28make -j$(nproc)
29make install
30
31cd $SRC/libidn2
32./bootstrap
33./configure --enable-static --disable-shared --disable-doc --disable-gcc-warnings --prefix=$WGET_DEPS_PATH --cache-file ../config.cache
34make -j$(nproc)
35make install
36
37cd $SRC/libpsl
38./autogen.sh
39./configure --enable-static --disable-shared --disable-gtk-doc --enable-runtime=libidn2 --enable-builtin=libidn2 --prefix=$WGET_DEPS_PATH --cache-file ../config.cache
40make -j$(nproc)
41make install
42
43GNUTLS_CONFIGURE_FLAGS=""
44NETTLE_CONFIGURE_FLAGS=""
45if [[ $CFLAGS = *sanitize=memory* ]]; then
46  GNUTLS_CONFIGURE_FLAGS="--disable-hardware-acceleration"
47  NETTLE_CONFIGURE_FLAGS="--disable-assembler --disable-fat"
48fi
49
50# We could use GMP from git repository to avoid false positives in
51# sanitizers, but GMP doesn't compile with clang. We use gmp-mini
52# instead.
53cd $SRC/nettle
54bash .bootstrap
55./configure --enable-mini-gmp --enable-static --disable-shared --disable-documentation --prefix=$WGET_DEPS_PATH $NETTLE_CONFIGURE_FLAGS --cache-file ../config.cache
56( make -j$(nproc) || make -j$(nproc) ) && make install
57if test $? != 0;then
58        echo "Failed to compile nettle"
59        exit 1
60fi
61
62cd $SRC/gnutls
63touch .submodule.stamp
64./bootstrap
65GNUTLS_CFLAGS=`echo $CFLAGS|sed s/-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION//`
66LIBS="-lunistring" \
67CFLAGS="$GNUTLS_CFLAGS" \
68./configure --with-nettle-mini --enable-gcc-warnings --enable-static --disable-shared --with-included-libtasn1 \
69    --with-included-unistring --without-p11-kit --disable-doc --disable-tests --disable-tools --disable-cxx \
70    --disable-maintainer-mode --disable-libdane --disable-gcc-warnings --disable-full-test-suite \
71    --prefix=$WGET_DEPS_PATH $GNUTLS_CONFIGURE_FLAGS
72make -j$(nproc)
73make install
74
75
76# avoid iconv() memleak on Ubuntu 16.04 image (breaks test suite)
77export ASAN_OPTIONS=detect_leaks=0
78
79# Ensure our libraries can be found
80ln -s $WGET_DEPS_PATH/lib64/libhogweed.a $WGET_DEPS_PATH/lib/libhogweed.a
81ln -s $WGET_DEPS_PATH/lib64/libnettle.a  $WGET_DEPS_PATH/lib/libnettle.a
82
83cd $SRC/wget
84./bootstrap
85autoreconf -fi
86
87export CFLAGS="$CFLAGS -I$WGET_DEPS_PATH/include"
88export CXXFLAGS="$CXXFLAGS -I$WGET_DEPS_PATH/include"
89
90# build and run non-networking tests
91GNUTLS_CFLAGS="-lgnutls" \
92GNUTLS_LIBS="-lgnutls" \
93LIBS="-lgnutls -lhogweed -lnettle -lidn2 -lunistring -lpsl" \
94./configure -C
95make clean
96make -j$(nproc)
97make -j$(nproc) -C fuzz check
98
99# build for fuzzing
100GNUTLS_CFLAGS="-lgnutls" \
101GNUTLS_LIBS="-lgnutls" \
102LIBS="-lgnutls -lhogweed -lnettle -lidn2 -lunistring -lpsl" \
103./configure --enable-fuzzing -C
104make clean
105make -j$(nproc) -C lib
106make -j$(nproc) -C src
107
108# build fuzzers
109cd fuzz
110make -j$(nproc) ../src/libunittest.a
111CXXFLAGS="$CXXFLAGS -L$WGET_DEPS_PATH/lib/" make oss-fuzz
112
113find . -name '*_fuzzer' -exec cp -v '{}' $OUT ';'
114find . -name '*_fuzzer.dict' -exec cp -v '{}' $OUT ';'
115find . -name '*_fuzzer.options' -exec cp -v '{}' $OUT ';'
116
117for dir in *_fuzzer.in; do
118  fuzzer=$(basename $dir .in)
119  zip -rj "$OUT/${fuzzer}_seed_corpus.zip" "${dir}/"
120done
121