diff options
author | jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> | 2018-06-26 10:00:23 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-26 10:00:23 -0700 |
commit | f5f98cf608cd6dfaca24fd726850e3bb84358ffc (patch) | |
tree | 67e53c453fd5ab3c22bfa6617eaa1c5f5bd77246 /projects/skia | |
parent | 9c2fe11666008c6a04de2c26715d6d343f2c5278 (diff) |
Build Skia with SwiftShader (#1573)
This requires building SwiftShader as well as changes to skia's
build. Reenables fuzzers that were disabled for AFL since we no
longer need to patch the binaries.
Also optimize invocations of git clone by adding --depth 1.
Diffstat (limited to 'projects/skia')
-rw-r--r-- | projects/skia/Dockerfile | 17 | ||||
-rw-r--r-- | projects/skia/build.sh | 148 |
2 files changed, 83 insertions, 82 deletions
diff --git a/projects/skia/Dockerfile b/projects/skia/Dockerfile index e1d54ee4..cbe792d9 100644 --- a/projects/skia/Dockerfile +++ b/projects/skia/Dockerfile @@ -17,15 +17,19 @@ FROM gcr.io/oss-fuzz-base/base-builder MAINTAINER kjlubick@chromium.org -RUN apt-get update && apt-get install -y python wget libglu1-mesa-dev patchelf +# Mesa needed to build swiftshader +RUN apt-get update && apt-get install -y python wget libglu1-mesa-dev cmake -RUN git clone 'https://chromium.googlesource.com/chromium/tools/depot_tools.git' +RUN git clone 'https://chromium.googlesource.com/chromium/tools/depot_tools.git' --depth 1 ENV PATH="${SRC}/depot_tools:${PATH}" -# checkout all sources needed to build your project -RUN git clone https://skia.googlesource.com/skia.git +RUN git clone https://swiftshader.googlesource.com/SwiftShader --depth 1 +WORKDIR SwiftShader +RUN git submodule update --init +WORKDIR .. + +RUN git clone https://skia.googlesource.com/skia.git --depth 1 -# current directory for build script WORKDIR skia RUN bin/sync @@ -86,3 +90,6 @@ COPY json.dict $SRC/skia/json.dict COPY BUILD.gn.diff $SRC/skia/BUILD.gn.diff RUN cat BUILD.gn.diff >> BUILD.gn + +# current directory for build script +WORKDIR ..
\ No newline at end of file diff --git a/projects/skia/build.sh b/projects/skia/build.sh index 80ec0bf0..c5340e7e 100644 --- a/projects/skia/build.sh +++ b/projects/skia/build.sh @@ -15,91 +15,89 @@ # ################################################################################ +# Build SwiftShader +cd SwiftShader +export SWIFTSHADER_INCLUDE_PATH=$PWD/include +rm -rf build +mkdir build + +cd build +if [ $SANITIZER == "profile" ]; then + cmake .. +elif [ $SANITIZER == "coverage" ]; then + # TODO(metzman): Remove this once "coverage" builds are removed from OSS-Fuzz. + CFLAGS= CXXFLAGS="-stdlib=libc++" cmake .. +else + if [ $SANITIZER == "address" ]; then + CMAKE_SANITIZER="ASAN" + elif [ $SANITIZER == "memory" ]; then + CMAKE_SANITIZER="MSAN" + elif [ $SANITIZER == "undefined" ]; then + CMAKE_SANITIZER="UBSAN" + else + exit 1 + fi + cmake .. -D$CMAKE_SANITIZER=1 +fi + +make -j +cp libGLESv2.so libEGL.so $OUT +export SWIFTSHADER_LIB_PATH=$OUT + +cd ../../skia # These are any clang warnings we need to silence. DISABLE="-Wno-zero-as-null-pointer-constant -Wno-unused-template -Wno-cast-qual -Wno-self-assign -Wno-return-std-move-in-c++11" # Disable UBSan vptr since target built with -fno-rtti. -export CFLAGS="$CFLAGS $DISABLE -fno-sanitize=vptr" -export CXXFLAGS="$CXXFLAGS $DISABLE -fno-sanitize=vptr" +export CFLAGS="$CFLAGS $DISABLE -I$SWIFTSHADER_INCLUDE_PATH -DGR_EGL_TRY_GLES3_THEN_GLES2 -fno-sanitize=vptr" +export CXXFLAGS="$CXXFLAGS $DISABLE -I$SWIFTSHADER_INCLUDE_PATH -DGR_EGL_TRY_GLES3_THEN_GLES2 -fno-sanitize=vptr "-DIS_FUZZING_WITH_LIBFUZZER"" +export LDFLAGS="-lFuzzingEngine $CXXFLAGS -L$SWIFTSHADER_LIB_PATH" # This splits a space separated list into a quoted, comma separated list for gn. export CFLAGS_ARR=`echo $CFLAGS | sed -e "s/\s/\",\"/g"` export CXXFLAGS_ARR=`echo $CXXFLAGS | sed -e "s/\s/\",\"/g"` - +export LDFLAGS_ARR=`echo $LDFLAGS | sed -e "s/\s/\",\"/g"` # Even though GPU is "enabled" for all these builds, none really # uses the gpu except for api_mock_gpu_canvas -$SRC/depot_tools/gn gen out/Fuzz_mem_constraints\ - --args='cc="'$CC'" - cxx="'$CXX'" - is_debug=false - extra_cflags_c=["'"$CFLAGS_ARR"'"] - extra_cflags_cc=["'"$CXXFLAGS_ARR"'","-DIS_FUZZING","-DIS_FUZZING_WITH_LIBFUZZER"] - skia_use_system_freetype2=false - skia_use_fontconfig=false - skia_enable_gpu=true - skia_enable_skottie=false - extra_ldflags=["-lFuzzingEngine", "'"$CXXFLAGS_ARR"'"]' $SRC/depot_tools/gn gen out/Fuzz\ --args='cc="'$CC'" cxx="'$CXX'" is_debug=false extra_cflags_c=["'"$CFLAGS_ARR"'"] - extra_cflags_cc=["'"$CXXFLAGS_ARR"'","-DIS_FUZZING_WITH_LIBFUZZER"] + extra_cflags_cc=["'"$CXXFLAGS_ARR"'"] + extra_ldflags=["'"$LDFLAGS_ARR"'"] + skia_use_egl=true skia_use_system_freetype2=false skia_use_fontconfig=false skia_enable_gpu=true - skia_enable_skottie=true - extra_ldflags=["-lFuzzingEngine", "'"$CXXFLAGS_ARR"'"]' - + skia_enable_skottie=true' -$SRC/depot_tools/ninja -C out/Fuzz_mem_constraints image_filter_deserialize - -# Don't build these fuzzers for AFL since it crashes on startup. -# This would cause a build breakage now that AFL has build checks. -# See https://github.com/google/oss-fuzz/issues/1338 for more details. -if [ "$FUZZING_ENGINE" == "libfuzzer" ] -then - $SRC/depot_tools/ninja -C out/Fuzz_mem_constraints api_raster_n32_canvas api_mock_gpu_canvas -fi - -set +e -for f in out/Fuzz_mem_constraints/*; do - # Remove unnecessary dependencies that aren't on runner containers. - # Libraries found through trial and error (ldd command also helpful). - # Note: GPU is also with the mem constraints options. - patchelf --remove-needed libGLU.so.1 $f - patchelf --remove-needed libGL.so.1 $f - patchelf --remove-needed libX11.so.6 $f -done -set -e +$SRC/depot_tools/gn gen out/Fuzz_mem_constraints\ + --args='cc="'$CC'" + cxx="'$CXX'" + is_debug=false + extra_cflags_c=["'"$CFLAGS_ARR"'"] + extra_cflags_cc=["'"$CXXFLAGS_ARR"'","-DIS_FUZZING"] + extra_ldflags=["'"$LDFLAGS_ARR"'"] + skia_use_egl=true + skia_use_system_freetype2=false + skia_use_fontconfig=false + skia_enable_gpu=true + skia_enable_skottie=false' $SRC/depot_tools/ninja -C out/Fuzz region_deserialize region_set_path \ - path_deserialize image_decode animated_image_decode \ - api_draw_functions api_gradients \ - api_path_measure png_encoder \ - jpeg_encoder webp_encoder skottie_json textblob_deserialize \ - skjson - -# Don't build these fuzzers for AFL since it crashes on startup. -# This would cause a build breakage now that AFL has build checks. -# See https://github.com/google/oss-fuzz/issues/1338 for more details. -if [ "$FUZZING_ENGINE" == "libfuzzer" ] -then - $SRC/depot_tools/ninja -C out/Fuzz api_null_canvas api_image_filter -fi + path_deserialize image_decode \ + animated_image_decode api_draw_functions \ + api_gradients api_path_measure png_encoder \ + jpeg_encoder webp_encoder skottie_json \ + textblob_deserialize skjson \ + api_null_canvas api_image_filter -set +e -for f in out/Fuzz/*; do - # Remove unnecessary dependencies that aren't on runner containers. - # Libraries found through trial and error (ldd command also helpful). - # Note: GPU is also with the mem constraints options. - patchelf --remove-needed libGLU.so.1 $f - patchelf --remove-needed libGL.so.1 $f - patchelf --remove-needed libX11.so.6 $f -done -set -e +$SRC/depot_tools/ninja -C out/Fuzz_mem_constraints image_filter_deserialize \ + api_raster_n32_canvas \ + api_mock_gpu_canvas cp out/Fuzz/region_deserialize $OUT/region_deserialize cp ./region_deserialize.options $OUT/region_deserialize.options @@ -170,22 +168,18 @@ cp out/Fuzz/skjson $OUT/skjson cp json.dict $OUT/skjson.dict cp ./skjson_seed_corpus.zip $OUT/skjson_seed_corpus.zip -# Handle libfuzzer only fuzzers (i.e. those that break afl-fuzz) -if [ "$FUZZING_ENGINE" == "libfuzzer" ] -then - cp out/Fuzz_mem_constraints/api_mock_gpu_canvas $OUT/api_mock_gpu_canvas - cp ./api_mock_gpu_canvas.options $OUT/api_mock_gpu_canvas.options - cp ./canvas_seed_corpus.zip $OUT/api_mock_gpu_canvas_seed_corpus.zip +cp out/Fuzz_mem_constraints/api_mock_gpu_canvas $OUT/api_mock_gpu_canvas +cp ./api_mock_gpu_canvas.options $OUT/api_mock_gpu_canvas.options +cp ./canvas_seed_corpus.zip $OUT/api_mock_gpu_canvas_seed_corpus.zip - cp out/Fuzz_mem_constraints/api_raster_n32_canvas $OUT/api_raster_n32_canvas - cp ./api_raster_n32_canvas.options $OUT/api_raster_n32_canvas.options - cp ./canvas_seed_corpus.zip $OUT/api_raster_n32_canvas_seed_corpus.zip +cp out/Fuzz_mem_constraints/api_raster_n32_canvas $OUT/api_raster_n32_canvas +cp ./api_raster_n32_canvas.options $OUT/api_raster_n32_canvas.options +cp ./canvas_seed_corpus.zip $OUT/api_raster_n32_canvas_seed_corpus.zip - cp out/Fuzz/api_image_filter $OUT/api_image_filter - cp ./api_image_filter.options $OUT/api_image_filter.options - cp ./api_image_filter_seed_corpus.zip $OUT/api_image_filter_seed_corpus.zip +cp out/Fuzz/api_image_filter $OUT/api_image_filter +cp ./api_image_filter.options $OUT/api_image_filter.options +cp ./api_image_filter_seed_corpus.zip $OUT/api_image_filter_seed_corpus.zip - cp out/Fuzz/api_null_canvas $OUT/api_null_canvas - cp ./api_null_canvas.options $OUT/api_null_canvas.options - cp ./canvas_seed_corpus.zip $OUT/api_null_canvas_seed_corpus.zip -fi +cp out/Fuzz/api_null_canvas $OUT/api_null_canvas +cp ./api_null_canvas.options $OUT/api_null_canvas.options +cp ./canvas_seed_corpus.zip $OUT/api_null_canvas_seed_corpus.zip |