Last active
September 23, 2023 16:13
-
-
Save yugr/c5478e1888f756448b09a710e99cca37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
In case of errors check https://stackoverflow.com/questions/56454026/building-libc-with-memorysanitizer-instrumentation-fails-due-to-memorysanitize