1#!/bin/bash -eu 2# Copyright 2020 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 18# Build zlib 19git clone --depth 1 -b master https://github.com/madler/zlib.git $SRC/zlib 20cd $SRC/zlib 21OLD_CFLAGS="$CFLAGS" 22export LDFLAGS="-fPIC $CFLAGS" 23export CFLAGS="-fPIC $CFLAGS" 24# Only build static libraries, so we don't accidentally link to zlib dynamically. 25./configure --static 26make -j$(nproc) clean 27make -j$(nproc) all install 28unset LDFLAGS 29export CFLAGS="$OLD_CFLAGS" 30 31# We're building `rdkit` using clang, but the boost package is built using gcc. 32# For whatever reason, linking would fail. 33# (Mismatch between libstdc++ and libc++ maybe?) 34# It works if we build `rdkit` using gcc or build boost using clang instead. 35# We've opted for building boost using clang. 36cd $SRC && \ 37wget --quiet https://sourceforge.net/projects/boost/files/boost/1.69.0/boost_1_69_0.tar.bz2 && \ 38tar xjf boost_1_69_0.tar.bz2 && \ 39cd $SRC/boost_1_69_0 && \ 40./bootstrap.sh --with-toolset=clang --with-libraries=serialization,system,iostreams,regex && \ 41./b2 -q -j$(nproc) toolset=clang linkflags="-fPIC $CXXFLAGS $CXXFLAGS_EXTRA" cxxflags="-fPIC $CXXFLAGS $CXXFLAGS_EXTRA" link=static install 42 43cd $SRC/rdkit 44 45mkdir -p build && cd build 46cmake -DRDK_BUILD_PYTHON_WRAPPERS=OFF -DRDK_BUILD_FREETYPE_SUPPORT=OFF -DLIB_FUZZING_ENGINE=${LIB_FUZZING_ENGINE} -DRDK_BUILD_FUZZ_TARGETS=ON -DRDK_INSTALL_STATIC_LIBS=ON -DBoost_USE_STATIC_LIBS=ON .. 47make -j$(nproc) 48make install 49 50# Leave build directory 51cd .. 52 53# Copy the fuzzer executables, zip-ed corpora, options and dictionary files to $OUT 54find . -type f -name '*_fuzzer' -exec cp -v '{}' $OUT ';' 55find . -type f -name '*_fuzzer.dict' -exec cp -v '{}' $OUT ';' 56#find . -type f -name '*_fuzzer.options' -exec cp -v '{}' $OUT ';' 57corpora=$(find . -type d -name "*_fuzzer") 58for corpus in $corpora; do 59 corpus_basename=$(basename $corpus) 60 zip -j $OUT/${corpus_basename}_seed_corpus.zip ${corpus}/* 61done 62