mirror of https://github.com/google/oss-fuzz.git
* [infra] Build libc++ and libc++abi with DFSan (#3388, #1632). * create a common function to reduce code duplication
This commit is contained in:
parent
016072db68
commit
05bafd4fcf
|
@ -41,6 +41,19 @@ function clone_with_retries {
|
|||
return $CHECKOUT_RETURN_CODE
|
||||
}
|
||||
|
||||
function cmake_llvm {
|
||||
extra_args="$@"
|
||||
cmake -G "Ninja" \
|
||||
-DLIBCXX_ENABLE_SHARED=OFF \
|
||||
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
|
||||
-DLIBCXXABI_ENABLE_SHARED=OFF \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DLLVM_TARGETS_TO_BUILD="$TARGET_TO_BUILD" \
|
||||
-DLLVM_ENABLE_PROJECTS="$PROJECTS_TO_BUILD" \
|
||||
$extra_args \
|
||||
$LLVM_SRC/llvm
|
||||
}
|
||||
|
||||
# Use chromium's clang revision
|
||||
mkdir $SRC/chromium_tools
|
||||
cd $SRC/chromium_tools
|
||||
|
@ -94,40 +107,33 @@ case $(uname -m) in
|
|||
esac
|
||||
|
||||
PROJECTS_TO_BUILD="libcxx;libcxxabi;compiler-rt;clang;lld"
|
||||
cmake -G "Ninja" \
|
||||
-DLIBCXX_ENABLE_SHARED=OFF -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON -DLIBCXXABI_ENABLE_SHARED=OFF \
|
||||
-DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="$TARGET_TO_BUILD" \
|
||||
-DLLVM_ENABLE_PROJECTS=$PROJECTS_TO_BUILD \
|
||||
$LLVM_SRC/llvm
|
||||
cmake_llvm
|
||||
ninja
|
||||
|
||||
cd $WORK/llvm-stage2
|
||||
export CC=$WORK/llvm-stage1/bin/clang
|
||||
export CXX=$WORK/llvm-stage1/bin/clang++
|
||||
cmake -G "Ninja" \
|
||||
-DLIBCXX_ENABLE_SHARED=OFF -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON -DLIBCXXABI_ENABLE_SHARED=OFF \
|
||||
-DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="$TARGET_TO_BUILD" \
|
||||
-DLLVM_ENABLE_PROJECTS=$PROJECTS_TO_BUILD \
|
||||
$LLVM_SRC/llvm
|
||||
cmake_llvm
|
||||
ninja
|
||||
ninja install
|
||||
rm -rf $WORK/llvm-stage1 $WORK/llvm-stage2
|
||||
|
||||
# Use the clang we just built from now on.
|
||||
CMAKE_EXTRA_ARGS="-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++"
|
||||
|
||||
# 32-bit libraries.
|
||||
mkdir -p $WORK/i386
|
||||
cd $WORK/i386
|
||||
cmake -G "Ninja" \
|
||||
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr/i386/ -DLIBCXX_ENABLE_SHARED=OFF \
|
||||
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_C_FLAGS="-m32" -DCMAKE_CXX_FLAGS="-m32" \
|
||||
-DLLVM_TARGETS_TO_BUILD="$TARGET_TO_BUILD" \
|
||||
-DLLVM_ENABLE_PROJECTS=$PROJECTS_TO_BUILD \
|
||||
$LLVM_SRC/llvm
|
||||
cmake_llvm $CMAKE_EXTRA_ARGS \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr/i386/ \
|
||||
-DCMAKE_C_FLAGS="-m32" \
|
||||
-DCMAKE_CXX_FLAGS="-m32"
|
||||
|
||||
ninja cxx
|
||||
ninja install-cxx
|
||||
rm -rf $WORK/i386
|
||||
|
||||
# MemorySanitizer instrumented libraries.
|
||||
mkdir -p $WORK/msan
|
||||
cd $WORK/msan
|
||||
|
||||
|
@ -136,19 +142,30 @@ cat <<EOF > $WORK/msan/blacklist.txt
|
|||
fun:__gxx_personality_*
|
||||
EOF
|
||||
|
||||
cmake -G "Ninja" \
|
||||
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
|
||||
-DLLVM_USE_SANITIZER=Memory -DCMAKE_INSTALL_PREFIX=/usr/msan/ \
|
||||
-DLIBCXX_ENABLE_SHARED=OFF -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
|
||||
-DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="$TARGET_TO_BUILD" \
|
||||
-DCMAKE_CXX_FLAGS="-fsanitize-blacklist=$WORK/msan/blacklist.txt" \
|
||||
-DLLVM_ENABLE_PROJECTS=$PROJECTS_TO_BUILD \
|
||||
$LLVM_SRC/llvm
|
||||
cmake_llvm $CMAKE_EXTRA_ARGS \
|
||||
-DLLVM_USE_SANITIZER=Memory \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr/msan/ \
|
||||
-DCMAKE_CXX_FLAGS="-fsanitize-blacklist=$WORK/msan/blacklist.txt"
|
||||
|
||||
ninja cxx
|
||||
ninja install-cxx
|
||||
rm -rf $WORK/msan
|
||||
|
||||
# DataFlowSanitizer instrumented libraries.
|
||||
mkdir -p $WORK/dfsan
|
||||
cd $WORK/dfsan
|
||||
|
||||
cmake_llvm $CMAKE_EXTRA_ARGS \
|
||||
-DLLVM_USE_SANITIZER=DataFlow \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr/dfsan/
|
||||
|
||||
ninja cxx cxxabi
|
||||
ninja install-cxx install-cxxabi
|
||||
rm -rf $WORK/dfsan
|
||||
|
||||
# libFuzzer sources.
|
||||
cp -r $LLVM_SRC/compiler-rt/lib/fuzzer $SRC/libfuzzer
|
||||
|
||||
# Cleanup
|
||||
rm -rf $LLVM_SRC
|
||||
rm -rf $SRC/chromium_tools
|
||||
|
|
Loading…
Reference in New Issue