Skip to content

Commit 2cb64df

Browse files
authored
Add a replay_build.sh for ffmpeg. (#13427)
This is meant to be a manual override over what chronos (https://github.com/google/oss-fuzz/tree/master/infra/experimental/chronos) generates. The idea is we'll snapshot the ffmpeg build container after running compile into a new Docker image. This image will have build artifacts saved so that subsequent `make` calls only trigger on changed files. This makes rebuilding a specific target **a lot** faster (From 2600 seconds down to instantaneous). This does change the `build.sh` -- merging the two ./configure calls down to one in order to faciliate this.
1 parent 3fd0f14 commit 2cb64df

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

projects/ffmpeg/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ RUN git clone --depth 1 https://gitlab.xiph.org/xiph/theora.git
4141
RUN git clone --depth 1 https://gitlab.xiph.org/xiph/vorbis.git
4242
RUN git clone --depth 1 https://gitlab.gnome.org/GNOME/libxml2.git
4343

44-
COPY build.sh group_seed_corpus.py $SRC/
44+
COPY build.sh replay_build.sh group_seed_corpus.py $SRC/

projects/ffmpeg/build.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,15 @@ fi
218218
--disable-shared \
219219
--disable-doc \
220220
--disable-programs \
221+
--enable-demuxers \
221222
$FFMPEG_BUILD_ARGS
222223
make clean
223224
make -j$(nproc) install
224225

226+
if [[ -n ${CAPTURE_REPLAY_SCRIPT-} ]]; then
227+
exit 0
228+
fi
229+
225230
# Download test samples, will be used as seed corpus.
226231
# DISABLED.
227232
# TODO: implement a better way to maintain a minimized seed corpora
@@ -274,6 +279,8 @@ if [ -n "${OSS_FUZZ_CI-}" ]; then
274279
CONDITIONALS=(${CONDITIONALS[@]:0:2})
275280
fi
276281

282+
# FIXME: currently, enc fuzzers are clobbering dec variants because they share the same
283+
# name.
277284
for c in $CONDITIONALS; do
278285
fuzzer_name=ffmpeg_AV_CODEC_ID_${c}_fuzzer
279286
symbol=$(echo $c | sed "s/.*/\L\0/")
@@ -315,7 +322,7 @@ fuzzer_name=ffmpeg_IO_DEMUXER_fuzzer
315322
make tools/target_io_dem_fuzzer
316323
mv tools/target_io_dem_fuzzer $OUT/${fuzzer_name}
317324

318-
#Build fuzzers for individual demuxers
325+
# Reduce size of demuxer fuzzers by disabling various components.
319326
./configure \
320327
--cc=$CC --cxx=$CXX --ld="$CXX $CXXFLAGS -std=c++11" \
321328
--extra-cflags="-I$FFMPEG_DEPS_PATH/include" \

projects/ffmpeg/replay_build.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash -eux
2+
# Copyright 2025 Google LLC
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+
# Disable UBSan vptr since several targets built with -fno-rtti.
19+
export CFLAGS="$CFLAGS -fno-sanitize=vptr"
20+
export CXXFLAGS="$CXXFLAGS -fno-sanitize=vptr"
21+
22+
if [[ "$CXXFLAGS" == *"-fsanitize=address"* ]]; then
23+
export CXXFLAGS="$CXXFLAGS -fno-sanitize-address-use-odr-indicator"
24+
fi
25+
26+
if [[ "$CFLAGS" == *"-fsanitize=address"* ]]; then
27+
export CFLAGS="$CFLAGS -fno-sanitize-address-use-odr-indicator"
28+
fi
29+
30+
if [[ "$ARCHITECTURE" == i386 ]]; then
31+
export CFLAGS="$CFLAGS -m32"
32+
export CXXFLAGS="$CXXFLAGS -m32"
33+
fi
34+
35+
# The option `-fuse-ld=gold` can't be passed via `CFLAGS` or `CXXFLAGS` because
36+
# Meson injects `-Werror=ignored-optimization-argument` during compile tests.
37+
# Remove the `-fuse-ld=` and let Meson handle it.
38+
# https://github.com/mesonbuild/meson/issues/6377#issuecomment-575977919
39+
export MESON_CFLAGS="$CFLAGS"
40+
if [[ "$CFLAGS" == *"-fuse-ld=gold"* ]]; then
41+
export MESON_CFLAGS="${CFLAGS//-fuse-ld=gold/}"
42+
export CC_LD=gold
43+
fi
44+
export MESON_CXXFLAGS="$CXXFLAGS"
45+
if [[ "$CXXFLAGS" == *"-fuse-ld=gold"* ]]; then
46+
export MESON_CXXFLAGS="${CXXFLAGS//-fuse-ld=gold/}"
47+
export CXX_LD=gold
48+
fi
49+
50+
cd $SRC/ffmpeg
51+
make -j$(nproc) install
52+
53+
if [ "$#" -lt 1 ]; then
54+
exit 0
55+
fi
56+
57+
name=$(echo "$1" | sed -E 's/ffmpeg_(AV_CODEC_ID_)?(.*)_fuzzer/\L\2/' | sed 's/demuxer/dem/')
58+
make tools/target_${name}_fuzzer || true
59+
if [ -f tools/target_${name}_fuzzer ]; then
60+
mv tools/target_${name}_fuzzer $OUT/$1
61+
fi
62+
63+
make tools/target_dec_${name}_fuzzer || true
64+
if [ -f tools/target_dec_${name}_fuzzer ]; then
65+
mv tools/target_dec_${name}_fuzzer $OUT/$1
66+
fi
67+
68+
make tools/target_enc_${name}_fuzzer || true
69+
if [ -f tools/target_enc_${name}_fuzzer ]; then
70+
mv tools/target_enc_${name}_fuzzer $OUT/$1
71+
fi

0 commit comments

Comments
 (0)