[compiler-rt] f4092c7 - [compiler-rt][test] Ensure CMAKE_SYSROOT is added as a test cflag if provided

Leonard Chan via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 16 17:14:25 PDT 2021


Author: Leonard Chan
Date: 2021-09-16T17:14:14-07:00
New Revision: f4092c769031f4dde5844ce57f1d47a7e7080311

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

LOG: [compiler-rt][test] Ensure CMAKE_SYSROOT is added as a test cflag if provided

When running tests like SanitizerCommon-asan-x86_64-Linux :: Linux/crypt_r.cpp,
it may attempt to use the host header crypt.h rather than a sysroot header.
This is significant in the event where struct crypt_data defined on host is
different from the sysroot used to make the sanitizer runtime libraries. This
can result in logical differences between the expected size/layout of struct
crypt_data known by sanitizers and the strict crypt_data provided by the host crypt.h.

Since tests should still use the CMAKE_SYSROOT, this ensures that CMAKE_SYSROOT
is propagated to compiler-rt tests.

Differential Revision: https://reviews.llvm.org/D109796

Added: 
    

Modified: 
    compiler-rt/test/sanitizer_common/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/sanitizer_common/CMakeLists.txt b/compiler-rt/test/sanitizer_common/CMakeLists.txt
index a759815c03763..f28ab0f627350 100644
--- a/compiler-rt/test/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/test/sanitizer_common/CMakeLists.txt
@@ -77,6 +77,9 @@ foreach(tool ${SUPPORTED_TOOLS})
     # 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()


        


More information about the llvm-commits mailing list