aboutsummaryrefslogtreecommitdiffhomepage
path: root/projects
diff options
context:
space:
mode:
authorGravatar Ammar Askar <ammar_askar@hotmail.com>2019-06-10 11:13:22 -0700
committerGravatar mbarbella-chromium <41697236+mbarbella-chromium@users.noreply.github.com>2019-06-10 11:13:22 -0700
commitff4bae9c43d138ad76e684b59dbacf9dbcd66aab (patch)
tree0e15c9997d63243e9404d426e565562c3106656b /projects
parent1f0a33c71256ebd0ef45c1e69762d2ba5c011b0d (diff)
Create docker and build files for cpython3 (#2493)
* Create docker and build files for cpython * Remove temporary patch (merged upstream)
Diffstat (limited to 'projects')
-rw-r--r--projects/cpython3/Dockerfile12
-rw-r--r--projects/cpython3/build.sh36
-rw-r--r--projects/cpython3/project.yaml2
3 files changed, 49 insertions, 1 deletions
diff --git a/projects/cpython3/Dockerfile b/projects/cpython3/Dockerfile
new file mode 100644
index 00000000..154076bb
--- /dev/null
+++ b/projects/cpython3/Dockerfile
@@ -0,0 +1,12 @@
+FROM gcr.io/oss-fuzz-base/base-builder
+LABEL maintainer="aaskar@google.com; ammar@ammaraskar.com"
+
+RUN apt-get update
+RUN apt-get install -y build-essential libncursesw5-dev \
+ libreadline-dev libssl-dev libgdbm-dev \
+ libc6-dev libsqlite3-dev tk-dev libbz2-dev \
+ zlib1g-dev libffi-dev
+
+RUN git clone https://github.com/python/cpython.git cpython3
+WORKDIR cpython3
+COPY build.sh $SRC/
diff --git a/projects/cpython3/build.sh b/projects/cpython3/build.sh
new file mode 100644
index 00000000..8d22f02a
--- /dev/null
+++ b/projects/cpython3/build.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# Ignore memory leaks from python scripts invoked in the build
+export ASAN_OPTIONS="detect_leaks=0"
+
+# Remove -pthread from CFLAGS, this trips up ./configure
+# which thinks pthreads are available without any CLI flags
+CFLAGS=${CFLAGS//"-pthread"/}
+
+FLAGS=""
+case $SANITIZER in
+ address)
+ FLAGS="--with-address-sanitizer"
+ ;;
+ memory)
+ FLAGS="--with-memory-sanitizer"
+ ;;
+ undefined)
+ FLAGS="--with-undefined-behavior-sanitizer"
+ ;;
+esac
+./configure $FLAGS --prefix $OUT
+
+make -j$(nproc) install
+
+FUZZ_DIR=Modules/_xxtestfuzz
+for fuzz_test in $(cat $FUZZ_DIR/fuzz_tests.txt)
+do
+ # Build (but don't link) the fuzzing stub with a C compiler
+ $CC $CFLAGS $($OUT/bin/python3-config --cflags) $FUZZ_DIR/fuzzer.c \
+ -D _Py_FUZZ_ONE -D _Py_FUZZ_$fuzz_test -c -Wno-unused-function \
+ -o $WORK/$fuzz_test.o
+ # Link with C++ compiler to appease libfuzzer
+ $CXX $CXXFLAGS $WORK/$fuzz_test.o -o $OUT/$fuzz_test \
+ $LIB_FUZZING_ENGINE $($OUT/bin/python3-config --ldflags --embed)
+done
diff --git a/projects/cpython3/project.yaml b/projects/cpython3/project.yaml
index 7996b044..522054f5 100644
--- a/projects/cpython3/project.yaml
+++ b/projects/cpython3/project.yaml
@@ -1,5 +1,5 @@
homepage: "https://python.org/"
primary_contact: "gps@google.com"
auto_ccs:
- - "jeanpierreda@google.com"
- "alex.gaynor@gmail.com"
+experimental: True