[compiler-rt] a72d784 - [runtimes] Disable sanitizers for configuration checks with --unwindlib=none (#227092)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 05:52:45 PDT 2026


Author: Joseph Huber
Date: 2026-09-29T07:52:31-05:00
New Revision: a72d784c52d0913e2f3b8e6b6588bf6b769d78dc

URL: https://github.com/llvm/llvm-project/commit/a72d784c52d0913e2f3b8e6b6588bf6b769d78dc
DIFF: https://github.com/llvm/llvm-project/commit/a72d784c52d0913e2f3b8e6b6588bf6b769d78dc.diff

LOG: [runtimes] Disable sanitizers for configuration checks with --unwindlib=none (#227092)

Summary:
in a sanitized runtimes build, every configuration check is linked with
both -fsanitize=... and --unwindlib=none and fails, because the
sanitizer runtimes need the unwinder. This completes an existing TODO by
suppressing this for the compiler flag checks in this configuration.
This shouldn't affect any existing users. Motivation is compiling
`+asan` multilibs for existing OpenMP/Offloading configurations.

Added: 
    

Modified: 
    compiler-rt/cmake/config-ix.cmake
    runtimes/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index e1abc7eb5c44e..d411cf014dd34 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -926,7 +926,7 @@ else()
 endif()
 
 #TODO(kostyak): add back Android & Fuchsia when the code settles a bit.
-if (SCUDO_STANDALONE_SUPPORTED_ARCH AND
+if (SCUDO_STANDALONE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
     COMPILER_RT_BUILD_SANITIZERS AND
     "scudo_standalone" IN_LIST COMPILER_RT_SANITIZERS_TO_BUILD AND
     OS_NAME MATCHES "Linux" AND

diff  --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index 61cf25af22870..a0ec44617c9c7 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -156,13 +156,6 @@ filter_prefixed("${CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} C
 # The compiler driver may be implicitly trying to link against libunwind,
 # which might not work if libunwind doesn't exist yet. Try to check if
 # --unwindlib=none is supported, and use that if possible.
-#
-# TODO: Note that this is problematic when LLVM_USE_SANITIZER is used
-# because some sanitizers require the unwinder and so the combination of
-# -fsanitize=... --unwindlib=none will always result in a linking error.
-# Currently, we counteract this issue by adding -fno-sanitize=all flag in
-# the project specific code within */cmake/config-ix.cmake files but that's
-# brittle. We should ideally move this to runtimes/CMakeLists.txt.
 llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
 if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
   set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
@@ -186,6 +179,13 @@ if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
   if (C_SUPPORTS_START_NO_UNUSED_ARGUMENTS)
     set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS} --start-no-unused-arguments --unwindlib=none --end-no-unused-arguments")
   endif()
+
+  # Some sanitizers require the unwinder, so the LLVM_USE_SANITIZER flags added
+  # by HandleLLVMOptions cannot link with --unwindlib=none. This only suppresses
+  # using sanitizers for the internal CMake compiler flag checks.
+  if (LLVM_USE_SANITIZER)
+    set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
+  endif()
 endif()
 
 # Disable use of the installed C++ standard library when building runtimes.


        


More information about the llvm-commits mailing list