• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2# Copyright 2018 Google Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16################################################################################
17
18# Build libvpx
19build_dir=$WORK/build
20rm -rf ${build_dir}
21mkdir -p ${build_dir}
22pushd ${build_dir}
23
24# oss-fuzz has 2 GB total memory allocation limit. So, we limit per-allocation
25# limit in libvpx to 1 GB to avoid OOM errors. A smaller per-allocation is
26# needed for MemorySanitizer (see bug oss-fuzz:9497 and bug oss-fuzz:9499).
27if [[ $CFLAGS = *sanitize=memory* ]]; then
28  extra_c_flags='-DVPX_MAX_ALLOCABLE_MEMORY=536870912'
29else
30  extra_c_flags='-DVPX_MAX_ALLOCABLE_MEMORY=1073741824'
31fi
32
33LDFLAGS="$CXXFLAGS" LD=$CXX $SRC/libvpx/configure \
34    --enable-vp9-highbitdepth \
35    --disable-unit-tests \
36    --disable-examples \
37    --size-limit=12288x12288 \
38    --extra-cflags="${extra_c_flags}" \
39    --disable-webm-io \
40    --enable-debug \
41    --disable-vp8-encoder \
42    --disable-vp9-encoder
43make -j$(nproc) all
44popd
45
46# build fuzzers
47fuzzer_src_name=vpx_dec_fuzzer
48fuzzer_decoders=( 'vp9' 'vp8' )
49for decoder in "${fuzzer_decoders[@]}"; do
50  fuzzer_name=${fuzzer_src_name}"_"${decoder}
51
52  $CXX $CXXFLAGS -std=c++11 \
53    -DDECODER=${decoder} \
54    -I$SRC/libvpx \
55    -I${build_dir} \
56    -Wl,--start-group \
57    $LIB_FUZZING_ENGINE \
58    $SRC/libvpx/examples/${fuzzer_src_name}.cc -o $OUT/${fuzzer_name} \
59    ${build_dir}/libvpx.a \
60    -Wl,--end-group
61  cp $SRC/vpx_fuzzer_seed_corpus.zip $OUT/${fuzzer_name}_seed_corpus.zip
62  cp $SRC/vpx_dec_fuzzer.dict $OUT/${fuzzer_name}.dict
63done
64