mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-05 08:09:07 +08:00
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:
committed by
Andrii Nakryiko
parent
9823ef295d
commit
dac1ec64a3
@@ -35,44 +35,48 @@ 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
|
||||||
rm -rf elfutils
|
if [[ ! -e elfutils || "$SKIP_LIBELF_REBUILD" == "" ]]; then
|
||||||
git clone https://sourceware.org/git/elfutils.git
|
rm -rf elfutils
|
||||||
(
|
git clone https://sourceware.org/git/elfutils.git
|
||||||
cd elfutils
|
(
|
||||||
git checkout 67a187d4c1790058fc7fd218317851cb68bb087c
|
cd elfutils
|
||||||
git log --oneline -1
|
git checkout 67a187d4c1790058fc7fd218317851cb68bb087c
|
||||||
|
git log --oneline -1
|
||||||
|
|
||||||
# ASan isn't compatible with -Wl,--no-undefined: https://github.com/google/sanitizers/issues/380
|
# ASan isn't compatible with -Wl,--no-undefined: https://github.com/google/sanitizers/issues/380
|
||||||
sed -i 's/^\(NO_UNDEFINED=\).*/\1/' configure.ac
|
sed -i 's/^\(NO_UNDEFINED=\).*/\1/' configure.ac
|
||||||
|
|
||||||
# ASan isn't compatible with -Wl,-z,defs either:
|
# ASan isn't compatible with -Wl,-z,defs either:
|
||||||
# https://clang.llvm.org/docs/AddressSanitizer.html#usage
|
# https://clang.llvm.org/docs/AddressSanitizer.html#usage
|
||||||
sed -i 's/^\(ZDEFS_LDFLAGS=\).*/\1/' configure.ac
|
sed -i 's/^\(ZDEFS_LDFLAGS=\).*/\1/' configure.ac
|
||||||
|
|
||||||
if [[ "$SANITIZER" == undefined ]]; then
|
if [[ "$SANITIZER" == undefined ]]; then
|
||||||
# That's basicaly what --enable-sanitize-undefined does to turn off unaligned access
|
# That's basicaly what --enable-sanitize-undefined does to turn off unaligned access
|
||||||
# elfutils heavily relies on on i386/x86_64 but without changing compiler flags along the way
|
# elfutils heavily relies on on i386/x86_64 but without changing compiler flags along the way
|
||||||
sed -i 's/\(check_undefined_val\)=[0-9]/\1=1/' configure.ac
|
sed -i 's/\(check_undefined_val\)=[0-9]/\1=1/' configure.ac
|
||||||
|
fi
|
||||||
|
|
||||||
|
autoreconf -i -f
|
||||||
|
if ! ./configure --enable-maintainer-mode --disable-debuginfod --disable-libdebuginfod \
|
||||||
|
--disable-demangler --without-bzlib --without-lzma --without-zstd \
|
||||||
|
CC="$CC" CFLAGS="-Wno-error $CFLAGS" CXX="$CXX" CXXFLAGS="-Wno-error $CXXFLAGS" LDFLAGS="$CFLAGS"; then
|
||||||
|
cat config.log
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
make -C config -j$(nproc) V=1
|
||||||
|
make -C lib -j$(nproc) V=1
|
||||||
|
make -C libelf -j$(nproc) V=1
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
autoreconf -i -f
|
|
||||||
if ! ./configure --enable-maintainer-mode --disable-debuginfod --disable-libdebuginfod \
|
|
||||||
--disable-demangler --without-bzlib --without-lzma --without-zstd \
|
|
||||||
CC="$CC" CFLAGS="-Wno-error $CFLAGS" CXX="$CXX" CXXFLAGS="-Wno-error $CXXFLAGS" LDFLAGS="$CFLAGS"; then
|
|
||||||
cat config.log
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
make -C config -j$(nproc) V=1
|
|
||||||
make -C lib -j$(nproc) V=1
|
|
||||||
make -C libelf -j$(nproc) V=1
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user