Skip to content

Commit

Permalink
oss-fuzz: build our own libc++-16
Browse files Browse the repository at this point in the history
oss-fuzz comes with LLVM15-ish, but that (aside from macOS,
which comes with LLVM16), is the only libc++-based distro,
so it looks like we can get away with requiring libc++-16.

It is a pity that we have to support clang-15,
but that is much more invasive of a change.

Refs. google/oss-fuzz#9989
  • Loading branch information
LebedevRI committed Feb 16, 2024
1 parent c4b1f70 commit 34851e5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .ci/oss-fuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ export CMAKE_GENERATOR=Ninja

ln -f -s /usr/local/bin/lld /usr/bin/ld

cd "$SRC"

wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.6/llvm-project-16.0.6.src.tar.xz
tar -xf llvm-project-16.0.6.src.tar.xz llvm-project-16.0.6.src/{runtimes,cmake,llvm/cmake,libcxx,libcxxabi}/
LIBCXX_BUILD="$SRC/llvm-project-16.0.6.build"
mkdir "$LIBCXX_BUILD"
cmake -S llvm-project-16.0.6.src/runtimes/ -B "$LIBCXX_BUILD" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
-DLIBCXX_ENABLE_SHARED=OFF \
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
-DLIBCXXABI_ENABLE_SHARED=OFF \
-DLIBCXX_INCLUDE_BENCHMARKS=OFF \
-DLIBCXXABI_ADDITIONAL_COMPILE_FLAGS="-fno-sanitize=vptr"
cmake --build "$LIBCXX_BUILD" -- -j$(nproc) cxx cxxabi

CXXFLAGS="$CXXFLAGS -nostdinc++ -nostdlib++ -isystem $LIBCXX_BUILD/include -isystem $LIBCXX_BUILD/include/c++/v1 -L$LIBCXX_BUILD/lib -lc++ -lc++abi"

if [[ $SANITIZER = *undefined* ]]; then
CFLAGS="$CFLAGS -fsanitize=unsigned-integer-overflow -fno-sanitize-recover=unsigned-integer-overflow"
CXXFLAGS="$CXXFLAGS -fsanitize=unsigned-integer-overflow -fno-sanitize-recover=unsigned-integer-overflow"
Expand Down

0 comments on commit 34851e5

Please sign in to comment.