Skip to content

Commit faea58a

Browse files
committed
[compiler-rt][test] Apply CFLAGS from sanitizer_common to all tests
Sanitizer-specific tests don't use the sanitizer_common flags, but the issues they address probably also apply to the individual sanitizers. This was observed in #119071: moving a test from sanitizer_common to msan broke it in builds with CMAKE_SYSROOT set, because the --sysroot argument was no longer applied to the test.
1 parent 75e5643 commit faea58a

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

compiler-rt/cmake/config-ix.cmake

+8
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,14 @@ macro(get_test_cc_for_arch arch cc_out cflags_out)
309309
endif()
310310
string(REPLACE ";" " " ${cflags_out} "${${cflags_out}}")
311311
endif()
312+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ANDROID)
313+
# ARM on Linux might use the slow unwinder as default and the unwind table
314+
# is required to get a complete stacktrace.
315+
string(APPEND ${cflags_out} " -funwind-tables")
316+
if(CMAKE_SYSROOT)
317+
string(APPEND ${cflags_out} " --sysroot=${CMAKE_SYSROOT}")
318+
endif()
319+
endif()
312320
endmacro()
313321

314322
# Returns CFLAGS that should be used to run tests for the

compiler-rt/test/sanitizer_common/CMakeLists.txt

-11
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,6 @@ foreach(tool ${SUPPORTED_TOOLS})
7373
get_test_cc_for_arch(${arch} SANITIZER_COMMON_TEST_TARGET_CC SANITIZER_COMMON_TEST_TARGET_CFLAGS)
7474
set(CONFIG_NAME ${tool}-${arch}-${OS_NAME})
7575

76-
# ARM on Linux might use the slow unwinder as default and the unwind table is
77-
# required to get a complete stacktrace.
78-
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND NOT ANDROID)
79-
list(APPEND SANITIZER_COMMON_TEST_TARGET_CFLAGS -funwind-tables)
80-
if(CMAKE_SYSROOT)
81-
list(APPEND SANITIZER_COMMON_TEST_TARGET_CFLAGS "--sysroot=${CMAKE_SYSROOT}")
82-
endif()
83-
string(REPLACE ";" " " SANITIZER_COMMON_TEST_TARGET_CFLAGS
84-
"${SANITIZER_COMMON_TEST_TARGET_CFLAGS}")
85-
endif()
86-
8776
configure_lit_site_cfg(
8877
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
8978
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py)

0 commit comments

Comments
 (0)