Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pillow] Pillow build improvements #4929

Merged
merged 6 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 25 additions & 18 deletions projects/pillow/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,37 @@ RUN cat fuzzing/dictionaries/bmp.dict \
fuzzing/dictionaries/tiff.dict \
fuzzing/dictionaries/webp.dict \
> $OUT/fuzz_pillow.dict

# library build dependencies
RUN apt-get install -y \
libfreetype6-dev \
libfribidi-dev \
libharfbuzz-dev \
libjpeg-dev \
liblcms2-dev \
libopenjp2-7-dev \
libpng-dev \
libtiff-dev \
libwebp-dev \
libx11-xcb-dev \
libxcb-render0-dev \
libxcb-xfixes0-dev \
libxcb1-dev \
libz-dev \
python3-tk \
tcl8.6-dev \
tk8.6-dev \
libxau-dev \
pkg-config \
rsync \
zlib1g-dev

RUN git clone --depth 1 https://github.com/python-pillow/Pillow
RUN git clone --depth 1 https://github.com/python-pillow/pillow-wheels

COPY build_depends.sh $SRC

RUN ln -s /usr/local/bin/python3 /usr/local/bin/python \
&& ln -s /bin/true /usr/local/bin/yum_install \
&& ln -s /bin/true /usr/local/bin/yum \
&& cd $SRC/pillow-wheels \
&& git submodule update --init multibuild \
&& bash $SRC/build_depends.sh

# install extra test images for a better starting corpus
RUN cd Pillow && depends/install_extra_test_images.sh

COPY build.sh $SRC/
COPY fuzz_* $SRC/Pillow

# pillow runtime dependencies
RUN apt-get install -y \
libfribidi-dev \
libharfbuzz-dev \
python3-tk \
tcl8.6-dev \
tk8.6-dev

WORKDIR $SRC/Pillow
23 changes: 13 additions & 10 deletions projects/pillow/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,23 @@
# limitations under the License.
#
################################################################################
make install-req
python3 setup.py develop

bp="$(find ./build -name '_imagingtk.o')"
BUILD_DIR="${bp/_imagingtk.o/}"
rm ${BUILD_DIR}/_imagingmath.o
rm ${BUILD_DIR}/_imagingtk.o
rm ${BUILD_DIR}/_imagingmorph.o
python3 setup.py build --build-base=/tmp/build install

TS="$(find ./src/PIL/ -name '_imaging.*.so')"
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 \
-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.
Expand Down
29 changes: 29 additions & 0 deletions projects/pillow/build_depends.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Copyright 2020 Eric Soroos
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This need to be copyright "Google LLC"
(if you don't want to do this, I suggest putting the file outside of the OSS-Fuzz repo and pulling it in)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: also 2021

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really care, it's not that big of a script, but it might wind up elsewhere.

However,

  • The tests asks for a license block, they do not state what license.
  • The contributing.md doesn't mention this, and specifically says:

    The CLA is necessary mainly because you own the copyright to your changes,

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use this license header. We can improve CONTRIBUTING.md later to mention this, any patches welcome to add it to that documentation

# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing perepo_managerissions and
# limitations under the License.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perepo_managerissions?

IANAL, but ... That doesn't look right.

I'm not even sure what autocorrect was on when it did that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is corrected one

# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


. multibuild/common_utils.sh

export CONFIGURE_BUILD_SOURCED=1
BUILD_PREFIX="${BUILD_PREFIX:-/usr/local}"
export CPPFLAGS="-I$BUILD_PREFIX/include $CPPFLAGS"
export LIBRARY_PATH="$BUILD_PREFIX/lib:$LIBRARY_PATH"
export PKG_CONFIG_PATH="$BUILD_PREFIX/lib/pkgconfig/:$PKG_CONFIG_PATH"

. multibuild/library_builders.sh
. config.sh

pre_build