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 f9d92d8 commit dc0251b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 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
5 changes: 3 additions & 2 deletions cmake/compiler-versions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ if(NOT DEFINED RAWSPEED_LIBCXX_MIN)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(LIBCXX_MIN 160000)
else()
# FIXME: really want libc++ 16.
set(LIBCXX_MIN 15000)
# Yes, even though we support using clang-15 (because of oss-fuzz),
# if you are using libc++, we require libc++-16.
set(LIBCXX_MIN 16000)
endif()
message(STATUS "Performing libc++ version check")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/libcpp_version_check.cpp"
Expand Down

0 comments on commit dc0251b

Please sign in to comment.