[compiler-rt] [compiler-rt][test] Apply CFLAGS from sanitizer_common to all tests (PR #120798)
Aaron Puchert via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 20 13:44:26 PST 2024
https://github.com/aaronpuchert created https://github.com/llvm/llvm-project/pull/120798
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.
>From 288b004a94ae16d197a99b2c68963b8ad684a506 Mon Sep 17 00:00:00 2001
From: Aaron Puchert <aaron.puchert at sap.com>
Date: Fri, 20 Dec 2024 22:35:27 +0100
Subject: [PATCH] [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.
---
compiler-rt/cmake/config-ix.cmake | 8 ++++++++
compiler-rt/test/sanitizer_common/CMakeLists.txt | 11 -----------
2 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index 6d52eecc9a91fe..09c15fdabfd09c 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -307,6 +307,14 @@ macro(get_test_cc_for_arch arch cc_out cflags_out)
if(APPLE)
list(APPEND ${cflags_out} ${DARWIN_osx_CFLAGS})
endif()
+ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ # ARM on Linux might use the slow unwinder as default and the unwind table
+ # is required to get a complete stacktrace.
+ list(APPEND ${cflags_out} -funwind-tables)
+ if(CMAKE_SYSROOT)
+ list(APPEND ${cflags_out} "--sysroot=${CMAKE_SYSROOT}")
+ endif()
+ endif()
string(REPLACE ";" " " ${cflags_out} "${${cflags_out}}")
endif()
endmacro()
diff --git a/compiler-rt/test/sanitizer_common/CMakeLists.txt b/compiler-rt/test/sanitizer_common/CMakeLists.txt
index 615666676f57ac..b044b9c6c3e088 100644
--- a/compiler-rt/test/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/test/sanitizer_common/CMakeLists.txt
@@ -73,17 +73,6 @@ foreach(tool ${SUPPORTED_TOOLS})
get_test_cc_for_arch(${arch} SANITIZER_COMMON_TEST_TARGET_CC SANITIZER_COMMON_TEST_TARGET_CFLAGS)
set(CONFIG_NAME ${tool}-${arch}-${OS_NAME})
- # ARM on Linux might use the slow unwinder as default and the unwind table is
- # required to get a complete stacktrace.
- if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND NOT ANDROID)
- list(APPEND SANITIZER_COMMON_TEST_TARGET_CFLAGS -funwind-tables)
- if(CMAKE_SYSROOT)
- list(APPEND SANITIZER_COMMON_TEST_TARGET_CFLAGS "--sysroot=${CMAKE_SYSROOT}")
- endif()
- string(REPLACE ";" " " SANITIZER_COMMON_TEST_TARGET_CFLAGS
- "${SANITIZER_COMMON_TEST_TARGET_CFLAGS}")
- endif()
-
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py)
More information about the llvm-commits
mailing list