Skip to content

Commit

Permalink
mercurial: move Python sources to $SRC and build in build.sh (#2078)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
durin42 authored and oliverchang committed Jan 9, 2019
1 parent 834a138 commit 658615d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion projects/mercurial/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
18 changes: 14 additions & 4 deletions projects/mercurial/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
===================================================================
Expand Down Expand Up @@ -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

0 comments on commit 658615d

Please sign in to comment.