[compiler-rt] 3a7c187 - [safestack] Support multilib testing (#98002)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 19 00:56:03 PDT 2024


Author: Rainer Orth
Date: 2024-07-19T09:55:59+02:00
New Revision: 3a7c187031ea4999e426565fa53282cf536158dd

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

LOG: [safestack] Support multilib testing (#98002)

While working on my safestack patches, I noticed that only the default
multilib was tested even though all multilib versions of
`libclang_rt.safestack.a` were built.

This patch fixes this, patterned after the ubsan testing support.

Tested on `amd64-pc-solaris2.11` (`amd64` and `i386`),
`sparcv9-sun-solaris2.11` (`sparcv9` and `sparc`), `x86_64-pc-linux-gnu`
(`x86_64` and `i386`), and `sparc64-unknown-linux-gnu` (`sparcv9` and
`sparc`).

Added: 
    

Modified: 
    compiler-rt/test/safestack/CMakeLists.txt
    compiler-rt/test/safestack/lit.cfg.py
    compiler-rt/test/safestack/lit.site.cfg.py.in

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/safestack/CMakeLists.txt b/compiler-rt/test/safestack/CMakeLists.txt
index 89ba6e74884b1..fca06024c9856 100644
--- a/compiler-rt/test/safestack/CMakeLists.txt
+++ b/compiler-rt/test/safestack/CMakeLists.txt
@@ -1,29 +1,40 @@
 set(SAFESTACK_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set(SAFESTACK_LIT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
+set(SAFESTACK_TESTSUITES)
 set(SAFESTACK_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
 list(APPEND SAFESTACK_TEST_DEPS safestack)
-if(NOT COMPILER_RT_STANDALONE_BUILD)
-  # Some tests require LTO, so add a dependency on the relevant LTO plugin.
-  if(LLVM_ENABLE_PIC)
-    if(LLVM_BINUTILS_INCDIR)
-      list(APPEND SAFESTACK_TEST_DEPS
-        LLVMgold
-      )
-    endif()
-    if(APPLE)
-      list(APPEND SAFESTACK_TEST_DEPS
-        LTO
-      )
+
+macro(add_safestack_testsuite test_mode sanitizer arch)
+  set(SAFESTACK_LIT_TEST_MODE "${test_mode}")
+  set(CONFIG_NAME ${SAFESTACK_LIT_TEST_MODE})
+
+  if(NOT COMPILER_RT_STANDALONE_BUILD)
+    # Some tests require LTO, so add a dependency on the relevant LTO plugin.
+    if(LLVM_ENABLE_PIC)
+      if(LLVM_BINUTILS_INCDIR)
+        list(APPEND SAFESTACK_TEST_DEPS LLVMgold)
+      endif()
+      if(APPLE)
+        list(APPEND SAFESTACK_TEST_DEPS LTO)
+      endif()
     endif()
   endif()
-endif()
+  set(CONFIG_NAME ${CONFIG_NAME}-${arch})
+  configure_lit_site_cfg(
+    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
+    ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py)
+  list(APPEND SAFESTACK_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
+endmacro()
+
+set(SAFESTACK_TEST_ARCH ${SAFESTACK_SUPPORTED_ARCH})
 
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
-  )
+foreach(arch ${SAFESTACK_TEST_ARCH})
+  set(SAFESTACK_TEST_TARGET_ARCH ${arch})
+  get_test_cc_for_arch(${arch} SAFESTACK_TEST_TARGET_CC SAFESTACK_TEST_TARGET_CFLAGS)
+  add_safestack_testsuite("Standalone" safestack ${arch})
+endforeach()
 
 add_lit_testsuite(check-safestack "Running the SafeStack tests"
-  ${CMAKE_CURRENT_BINARY_DIR}
+  ${SAFESTACK_TESTSUITES}
   DEPENDS ${SAFESTACK_TEST_DEPS})

diff  --git a/compiler-rt/test/safestack/lit.cfg.py b/compiler-rt/test/safestack/lit.cfg.py
index 17dfae46a412b..4ab9c1ce70bac 100644
--- a/compiler-rt/test/safestack/lit.cfg.py
+++ b/compiler-rt/test/safestack/lit.cfg.py
@@ -3,7 +3,7 @@
 import os
 
 # Setup config name.
-config.name = "SafeStack"
+config.name = "SafeStack-" + config.name_suffix
 
 # Setup source root.
 config.test_source_root = os.path.dirname(__file__)

diff  --git a/compiler-rt/test/safestack/lit.site.cfg.py.in b/compiler-rt/test/safestack/lit.site.cfg.py.in
index 3c8bf41b283b8..ee866bca2bad3 100644
--- a/compiler-rt/test/safestack/lit.site.cfg.py.in
+++ b/compiler-rt/test/safestack/lit.site.cfg.py.in
@@ -1,5 +1,11 @@
 @LIT_SITE_CFG_IN_HEADER@
 
+# Tool-specific config options.
+config.name_suffix = "@CONFIG_NAME@"
+config.safestack_lit_test_mode = "@SAFESTACK_LIT_TEST_MODE@"
+config.target_cflags = "@SAFESTACK_TEST_TARGET_CFLAGS@"
+config.target_arch = "@SAFESTACK_TEST_TARGET_ARCH@"
+
 # Load common config for all compiler-rt lit tests.
 lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
 


        


More information about the llvm-commits mailing list