Skip to content

Instantly share code, notes, and snippets.

@yugr
Last active September 23, 2023 16:13
Show Gist options
  • Save yugr/c5478e1888f756448b09a710e99cca37 to your computer and use it in GitHub Desktop.
Save yugr/c5478e1888f756448b09a710e99cca37 to your computer and use it in GitHub Desktop.
# Build llvm
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DLLVM_USE_SANITIZER="MemoryWithOrigins"
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -G Ninja \
-S runtimes -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
path/to/llvm
ninja -j32 install-cxx install-cxxabi
# Sanitize project
# May also need to set CMAKE_C_FLAGS
set(CMAKE_CXX_FLAGS "-g -fsanitize=memory -fno-omit-frame-pointer -fsanitize-memory-track-origins -nostdinc++ -isystem ${INSTALL_DIR}/include/c++/v1")
# May also need to set and CMAKE_SHARED_LINKER_FLAGS
set(CMAKE_EXE_LINKER_FLAGS "-Wno-error=unused-command-line-argument -fsanitize=memory -stdlib=libc++ -lc++abi -Wl,-rpath ${INSTALL_DIR}/lib -L${INSTALL_DIR}/lib")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment