mercurial: move Python sources to $SRC and build in build.sh (#2078)

This will clean up the Makefile on the hg side considerably, and will
also fix the coverage build. Fixes #2076.

Bonus: I did some extra work in build.sh so that incremental rebuilds
of the fuzzers won't needlessly recompile $OUT/sanpy, shortening
development time on new fuzzers and avoiding issues caused by a $OUT
that was built for a different fuzz configuration.
This commit is contained in:
Augie Fackler 2019-01-08 22:17:01 -05:00 committed by Oliver Chang
parent 834a138b39
commit 658615d59e
2 changed files with 15 additions and 5 deletions

View File

@ -18,7 +18,7 @@ FROM gcr.io/oss-fuzz-base/base-builder
MAINTAINER security@mercurial-scm.org
RUN apt-get update && apt-get install -y make autoconf automake libtool \
python-dev mercurial curl
RUN cd / && curl https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz | tar xzf -
RUN cd $SRC && curl https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz | tar xzf -
RUN hg clone https://www.mercurial-scm.org/repo/hg mercurial
WORKDIR mercurial
COPY build.sh $SRC/

View File

@ -15,8 +15,7 @@
#
################################################################################
pushd /Python-2.7.15/
ls
pushd $SRC/Python-2.7.15/
patch -p1 <<'EOF'
Index: v2_7_unstable/Python/pymath.c
===================================================================
@ -46,8 +45,19 @@ Index: v2_7_unstable/Modules/_ctypes/callproc.c
avalues = (void **)alloca(sizeof(void *) * argcount);
atypes = (ffi_type **)alloca(sizeof(ffi_type *) * argcount);
EOF
if [ -e $OUT/sanpy/cflags -a "$(cat $OUT/sanpy/cflags)" = "${CFLAGS}" ] ; then
echo 'Python cflags unchanged, no need to rebuild'
else
rm -rf $OUT/sanpy
ASAN_OPTIONS=detect_leaks=0 ./configure --without-pymalloc \
--prefix=$OUT/sanpy CFLAGS="${CFLAGS}" LINKCC="${CXX}" \
LDFLAGS="${CXXFLAGS}"
grep -v HAVE_GETC_UNLOCKED < pyconfig.h > tmp && mv tmp pyconfig.h
ASAN_OPTIONS=detect_leaks=0 make && make install
echo "${CFLAGS}" > $OUT/sanpy/cflags
fi
popd
cd contrib/fuzz
export PYLDFLAGS=$(echo $CFLAGS | xargs -n 1 echo | egrep -- '-fsanitize=(memory|address)')
make oss-fuzz
make clean oss-fuzz