After https://reviews.llvm.org/D146920 fixed the compiler check for it,
we're adding -ftrivial-auto-var-init=pattern to SANITIZER_COMMON_CFLAGS,
which can result in calls to memset. However, RTSanitizerCommon and
RTSanitizerCommonNoLibc are supposed to be independent of libc, which is
tested by Sanitizer-${arch}-Test-Nolibc, and that test was failing to
link as a result. Build these two libraries without auto var init to
avoid the libc dependency.
Details
- Reviewers
phosek leonardchan vitalybuka
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
10,940 ms | x64 debian > ThreadSanitizer-x86_64.Linux::check_memcpy.c |
Event Timeline
The test failure is occurring on the base revision as well, so it's not caused by my change.
compiler-rt/lib/sanitizer_common/CMakeLists.txt | ||
---|---|---|
223–224 | Could we alternatively add -ftrivial-auto-var-init=unititilized to override -ftrivial-auto-var-init=pattern that was added earlier? |
compiler-rt/lib/sanitizer_common/CMakeLists.txt | ||
---|---|---|
223–224 | I commented about that D135716, but didn't insist as to my surprise we see no symptoms. I didn't realize it's just quotes. Only tsan has a test for that, other sanitizers will have the same issue. I think safer to limit this flag to platforms without interceptors, like FUCSHIA, and find solution for general case later, like inserting special path to replace memsets with internal_memsets. |
There is an issue I unfortunately don't have time to figure out how to solve: check_cxx_compiler_flag uses CMAKE_CXX_FLAGS, which contains -Wall (implies -Wformat), but CMAKE_CXX_FLAGS is not used when building builtins (they are built as "custom targets").
As a result, when using gcc, check_cxx_compiler_flag("-Wformat-security -Werror" ...) passes, but the compilation fails because gcc doesn't like -Wformat-security without -Wformat.
I think CMAKE_CXX_FLAGS contains -Wall because of inclusion of AddLLVM.cmake somewhere in the runtimes.
Could we alternatively add -ftrivial-auto-var-init=unititilized to override -ftrivial-auto-var-init=pattern that was added earlier?