[Pillow] Use upstream support for fuzzing build (#5193)

* Don't worry about raqm/fonts for now.

* Current fuzzer doesn't test the font handling
* Upstream (pillow) changes are coming to packaging for raqm/harfbuzz/fribidi

* Use core setup.py options for build linking

explcitly copy libraries in pyinstaller
This commit is contained in:
wiredfool 2021-02-13 19:27:13 +00:00 committed by GitHub
parent 10083e6746
commit 38b1953417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 23 deletions

View File

@ -54,12 +54,10 @@ RUN cd Pillow && depends/install_extra_test_images.sh
COPY build.sh $SRC/
# pillow runtime dependencies
# pillow optional runtime dependencies
RUN apt-get install -y \
libfribidi-dev \
libharfbuzz-dev \
python3-tk \
tcl8.6-dev \
tk8.6-dev
python3-tk \
tcl8.6-dev \
tk8.6-dev
WORKDIR $SRC/Pillow

View File

@ -17,27 +17,21 @@
python3 setup.py build --build-base=/tmp/build install
bp="$(find /tmp/build -name '_imaging.o')"
BUILD_DIR="${bp/_imaging.o/}"
if [ -d "$BUILD_DIR" ]; then
find $BUILD_DIR -name _imagingmath.o -delete
find $BUILD_DIR -name _imagingtk.o -delete
find $BUILD_DIR -name _imagingmorph.o -delete
fi;
# Relink with fuzzing engine
TS="$(find /usr/local/lib/python3.* -name '_imaging.*.so')"
$CXX -pthread -shared $CXXFLAGS $LIB_FUZZING_ENGINE ${BUILD_DIR}/*.o ${BUILD_DIR}/libImaging/*.o \
-L/usr/local/lib -L/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu \
-L/usr/lib/x86_64-linux-gnu/libfakeroot -L/usr/lib -L/lib -L/usr/local/lib \
-ljpeg -lz -lxcb -lfreetype -lopenjp2 -ltiff -llcms2 -lwebp -lwebpmux -lwebpdemux \
-o ${TS} -stdlib=libc++
# Build fuzzers in $OUT.
for fuzzer in $(find $SRC -name 'fuzz_*.py'); do
fuzzer_basename=$(basename -s .py $fuzzer)
fuzzer_package=${fuzzer_basename}.pkg
pyinstaller --distpath $OUT --onefile --name $fuzzer_package $fuzzer
pyinstaller \
--add-binary /usr/local/lib/libjpeg.so.9:. \
--add-binary /usr/local/lib/libfreetype.so.6:. \
--add-binary /usr/local/lib/liblcms2.so.2:. \
--add-binary /usr/local/lib/libopenjp2.so.7:. \
--add-binary /usr/local/lib/libpng16.so.16:. \
--add-binary /usr/local/lib/libtiff.so.5:. \
--add-binary /usr/local/lib/libwebp.so.7:. \
--add-binary /usr/local/lib/libwebpdemux.so.2:. \
--add-binary /usr/local/lib/libwebpmux.so.3:. \
--distpath $OUT --onefile --name $fuzzer_package $fuzzer
# Create execution wrapper.
echo "#!/bin/sh