[libc-commits] [PATCH] D149629: [libc] Fix some missing features from the hermetic test support

Joseph Huber via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue May 2 07:40:50 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG2353b52eae71: [libc] Fix some missing features from the hermetic test support (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149629/new/

https://reviews.llvm.org/D149629

Files:
  libc/cmake/modules/LLVMLibCTestRules.cmake
  libc/test/UnitTest/CMakeLists.txt


Index: libc/test/UnitTest/CMakeLists.txt
===================================================================
--- libc/test/UnitTest/CMakeLists.txt
+++ libc/test/UnitTest/CMakeLists.txt
@@ -77,8 +77,6 @@
   RoundingModeUtils.cpp
   RoundingModeUtils.h
 )
-target_include_directories(LibcFPTestHelpers PUBLIC ${LIBC_SOURCE_DIR})
-target_link_libraries(LibcFPTestHelpers LibcUnitTest)
 add_dependencies(
   LibcFPTestHelpers
   LibcUnitTest
@@ -93,8 +91,6 @@
   MemoryMatcher.h
   MemoryMatcher.cpp
 )
-target_include_directories(LibcMemoryHelpers PUBLIC ${LIBC_SOURCE_DIR})
-target_link_libraries(LibcMemoryHelpers LibcUnitTest)
 add_dependencies(
   LibcMemoryHelpers
   LibcUnitTest
@@ -106,8 +102,6 @@
   PrintfMatcher.h
   PrintfMatcher.cpp
 )
-target_include_directories(LibcPrintfHelpers PUBLIC ${LIBC_SOURCE_DIR})
-target_link_libraries(LibcPrintfHelpers LibcUnitTest)
 add_dependencies(
   LibcPrintfHelpers
   LibcUnitTest
@@ -121,8 +115,6 @@
   ScanfMatcher.h
   ScanfMatcher.cpp
 )
-target_include_directories(LibcScanfHelpers PUBLIC ${LIBC_SOURCE_DIR})
-target_link_libraries(LibcScanfHelpers LibcUnitTest)
 add_dependencies(
   LibcScanfHelpers
   LibcUnitTest
@@ -130,3 +122,9 @@
   libc.src.stdio.scanf_core.core_structs
   libc.test.UnitTest.string_utils
 )
+
+foreach(lib LibcFPTestHelpers LibcMemoryHelpers LibcPrintfHelpers LibcScanfHelpers)
+  target_include_directories(${lib} PUBLIC ${LIBC_SOURCE_DIR})
+  target_compile_options(${lib} PRIVATE -fno-exceptions -fno-rtti)
+target_link_libraries(${lib} LibcUnitTest)
+endforeach()
Index: libc/cmake/modules/LLVMLibCTestRules.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCTestRules.cmake
+++ libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -568,6 +568,7 @@
 #     ARGS <list of command line arguments to be passed to the test>
 #     ENV <list of environment variables to set before running the test>
 #     COMPILE_OPTIONS <list of special compile options for the test>
+#     LINK_LIBRARIES <list of linking libraries for this target>
 #     LOADER_ARGS <list of special args to loaders (like the GPU loader)>
 #   )
 function(add_libc_hermetic_test test_name)
@@ -579,7 +580,7 @@
     "HERMETIC_TEST"
     "" # No optional arguments
     "SUITE" # Single value arguments
-    "SRCS;HDRS;DEPENDS;ARGS;ENV;COMPILE_OPTIONS;LOADER_ARGS" # Multi-value arguments
+    "SRCS;HDRS;DEPENDS;ARGS;ENV;COMPILE_OPTIONS;LINK_LIBRARIES;LOADER_ARGS" # Multi-value arguments
     ${ARGN}
   )
 
@@ -660,13 +661,15 @@
   target_link_options(${fq_build_target_name} PRIVATE -nostdlib -static)
   target_link_libraries(
     ${fq_build_target_name}
-    libc.startup.${LIBC_TARGET_OS}.crt1
-    LibcHermeticTestMain LibcHermeticTest
-    # The NVIDIA 'nvlink' linker does not currently support static libraries.
-    $<$<NOT:$<BOOL:${LIBC_GPU_TARGET_ARCHITECTURE_IS_NVPTX}>>:${fq_target_name}.__libc__>)
+    PRIVATE
+      ${HERMETIC_TEST_LINK_LIBRARIES}
+      libc.startup.${LIBC_TARGET_OS}.crt1
+      LibcHermeticTestMain LibcHermeticTest
+      # The NVIDIA 'nvlink' linker does not currently support static libraries.
+      $<$<NOT:$<BOOL:${LIBC_GPU_TARGET_ARCHITECTURE_IS_NVPTX}>>:${fq_target_name}.__libc__>)
   add_dependencies(${fq_build_target_name}
                    LibcHermeticTest
-                   ${HERMETIC_TEST_DEPENDS})
+                   ${fq_deps_list})
 
   # Tests on the GPU require an external loader utility to launch the kernel.
   if(TARGET libc.utils.gpu.loader)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149629.518729.patch
Type: text/x-patch
Size: 3507 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230502/8c8c3764/attachment.bin>


More information about the libc-commits mailing list