scripts: allow skipping elfutils rebuild in build-fuzzers.sh

This simplifies local reproduction of fuzzer reported errors.
E.g. the following sequence of commands would execute much faster on a
second run:

  $ SKIP_LIBELF_REBUILD=1 scripts/build-fuzzers.sh
  $ out/bpf-object-fuzzer <path-to-test-case>

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
This commit is contained in:
Eduard Zingerman
2025-07-18 16:42:07 -07:00
committed by Andrii Nakryiko
parent 9823ef295d
commit dac1ec64a3

View File

@@ -35,11 +35,14 @@ if [[ "$SANITIZER" == undefined ]]; then
CXXFLAGS+=" $UBSAN_FLAGS" CXXFLAGS+=" $UBSAN_FLAGS"
fi fi
export SKIP_LIBELF_REBUILD=${SKIP_LIBELF_REBUILD:=''}
# Ideally libbelf should be built using release tarballs available # Ideally libbelf should be built using release tarballs available
# at https://sourceware.org/elfutils/ftp/. Unfortunately sometimes they # at https://sourceware.org/elfutils/ftp/. Unfortunately sometimes they
# fail to compile (for example, elfutils-0.185 fails to compile with LDFLAGS enabled # fail to compile (for example, elfutils-0.185 fails to compile with LDFLAGS enabled
# due to https://bugs.gentoo.org/794601) so let's just point the script to # due to https://bugs.gentoo.org/794601) so let's just point the script to
# commits referring to versions of libelf that actually can be built # commits referring to versions of libelf that actually can be built
if [[ ! -e elfutils || "$SKIP_LIBELF_REBUILD" == "" ]]; then
rm -rf elfutils rm -rf elfutils
git clone https://sourceware.org/git/elfutils.git git clone https://sourceware.org/git/elfutils.git
( (
@@ -72,6 +75,7 @@ make -C config -j$(nproc) V=1
make -C lib -j$(nproc) V=1 make -C lib -j$(nproc) V=1
make -C libelf -j$(nproc) V=1 make -C libelf -j$(nproc) V=1
) )
fi
make -C src BUILD_STATIC_ONLY=y V=1 clean make -C src BUILD_STATIC_ONLY=y V=1 clean
make -C src -j$(nproc) CFLAGS="-I$(pwd)/elfutils/libelf $CFLAGS" BUILD_STATIC_ONLY=y V=1 make -C src -j$(nproc) CFLAGS="-I$(pwd)/elfutils/libelf $CFLAGS" BUILD_STATIC_ONLY=y V=1