Support MemorySanitizer build#1988
Open
kzall0c wants to merge 1 commit intonamhyung:masterfrom
Open
Conversation
Uninitialized values occur when stack- or heap-allocated memory is read before it is written. MSan detects cases * Uninitialized value was used in a conditional branch. * Uninitialized pointer was used for memory accesses. * Uninitialized value was passed or returned from a function call. * Uninitialized data was passed into some libc calls. $ git clone https://github.com/llvm/llvm-project.git $ cd ~/llvm-project/ $ mkdir build/ && cd build $ CC=clang CXX=clang++ cmake -G Ninja ../llvm \ -DLLVM_ENABLE_PROJECTS="clang;compiler-rt" \ -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ -DCOMPILER_RT_BUILD_SANITIZERS=ON \ -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \ -DLLVM_ENABLE_LIBCXX=ON \ -DLLVM_TARGETS_TO_BUILD="X86" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_COMPILER_TARGET=x86_64-unknown-linux-gnu $ ninja $ cd ~/uftrace/ $ ./configure CC=$HOME/llvm-project/build/bin/clang $ make MSAN=1 $ cd tests/ $ ./runtest.py -c=$HOME/llvm-project/build/bin/clang Signed-off-by: Yunseong Kim <yskelg@gmail.com>
namhyung
reviewed
Jan 9, 2025
| DBGINFO_CFLAGS += $(ASAN_CFLAGS) | ||
| TRACEEVENT_CFLAGS += $(ASAN_CFLAGS) | ||
| TEST_CFLAGS += $(ASAN_CFLAGS) | ||
| SAN=$(DEFAULT_SANITIZERS) |
| ifeq ($(SAN), all) | ||
| SAN_CFLAGS := -O0 -g -fsanitize=$(DEFAULT_SANITIZERS) | ||
| else ifeq ($(MSAN), 1) | ||
| SAN_CFLAGS := -O0 -g -fsanitize=$(SAN) -fsanitize-memory-track-origins |
Owner
There was a problem hiding this comment.
It seems it should be used when memory sanitizer is requested (even with others). What about this?
else ifneq ($(findstring memory, $(SAN)), )
SAN_CFLAGS := -O0 -g -fsanitize=$(SAN) -fsanitize-memory-track-origins
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uninitialized values occur when stack- or heap-allocated memory is read before it is written. MSan detects cases