aboutsummaryrefslogtreecommitdiff
path: root/projects/mercurial
diff options
context:
space:
mode:
authorAugie Fackler <raf@durin42.com>2019-01-08 22:17:01 -0500
committerOliver Chang <oliverchang@users.noreply.github.com>2019-01-09 14:17:01 +1100
commit658615d59e8bb1d7a6bf6cf62dcf49d4102423cc (patch)
treead64f5bc8efd1a76c45a37c90d3303f462191264 /projects/mercurial
parent834a138b396ddbc87f8bb1b4b9c67ac8630f5e6b (diff)
downloadoss-fuzz-658615d59e8bb1d7a6bf6cf62dcf49d4102423cc.tar.gz
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.
Diffstat (limited to 'projects/mercurial')
-rw-r--r--projects/mercurial/Dockerfile2
-rwxr-xr-xprojects/mercurial/build.sh18
2 files changed, 15 insertions, 5 deletions
diff --git a/projects/mercurial/Dockerfile b/projects/mercurial/Dockerfile
index 890c5237e..09b522093 100644
--- a/projects/mercurial/Dockerfile
+++ b/projects/mercurial/Dockerfile
@@ -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/
diff --git a/projects/mercurial/build.sh b/projects/mercurial/build.sh
index 58d0670d9..30ee28137 100755
--- a/projects/mercurial/build.sh
+++ b/projects/mercurial/build.sh
@@ -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