[libc-commits] [PATCH] D149303: [libc] Add a new target named LibcHermeticTestMain.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Apr 26 15:47:47 PDT 2023


sivachandra created this revision.
sivachandra added a reviewer: jhuber6.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added projects: libc-project, All.
sivachandra requested review of this revision.

The existing LibcTestMain has been renamed to LibcUnitTestMain.
Hermetic tests will be linked to this target.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149303

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
@@ -15,24 +15,35 @@
 
 add_library(
   LibcUnitTest
+  EXCLUDE_FROM_ALL
   ${libc_test_srcs_common}
   ${libc_death_test_srcs}
 )
 
 add_library(
   LibcHermeticTest
+  EXCLUDE_FROM_ALL
   ${libc_test_srcs_common}
   HermeticTestUtils.cpp
 )
 
-foreach(lib LibcUnitTest LibcHermeticTest)
+add_library(
+  LibcUnitTestMain
+  EXCLUDE_FROM_ALL
+  LibcTestMain.cpp
+)
+add_dependencies(LibcUnitTestMain LibcUnitTest)
+
+add_library(
+  LibcHermeticTestMain
+  EXCLUDE_FROM_ALL
+  LibcTestMain.cpp
+)
+add_dependencies(LibcHermeticTestMain LibcHermeticTest)
+
+foreach(lib LibcUnitTest LibcUnitTestMain LibcHermeticTest LibcHermeticTestMain)
   target_include_directories(${lib} PUBLIC ${LIBC_SOURCE_DIR})
-  if(LIBC_GPU_BUILD OR LIBC_GPU_ARCHITECTURES)
-    # If we are in full build mode, then we should use our own public headers.
-    target_include_directories(${lib} PRIVATE ${LIBC_BUILD_DIR}/include)
-  endif()
-  target_compile_options(${lib} PRIVATE ${LIBC_HERMETIC_TEST_COMPILE_OPTIONS}
-                         -fno-exceptions -fno-rtti)
+  target_compile_options(${lib} PRIVATE -fno-exceptions -fno-rtti)
   add_dependencies(${lib}
     libc.src.__support.c_string
     libc.src.__support.CPP.string
@@ -43,20 +54,11 @@
   )
 endforeach()
 
-target_compile_options(LibcHermeticTest PRIVATE -ffreestanding -nostdlib -nostdlib++)
-
-add_library(
-  LibcTestMain
-  LibcTestMain.cpp
-)
-
-target_include_directories(LibcTestMain PUBLIC ${LIBC_SOURCE_DIR})
-target_compile_options(LibcTestMain PRIVATE -fno-exceptions -fno-rtti)
-if(LIBC_GPU_BUILD OR LIBC_GPU_ARCHITECTURES)
-  target_include_directories(LibcTestMain PRIVATE ${LIBC_BUILD_DIR}/include)
-  target_compile_options(LibcTestMain PRIVATE ${LIBC_HERMETIC_TEST_COMPILE_OPTIONS})
-endif()
-add_dependencies(LibcTestMain LibcUnitTest)
+foreach(lib LibcHermeticTest LibcHermeticTestMain)
+  target_include_directories(${lib} PRIVATE ${LIBC_BUILD_DIR}/include)
+  target_compile_options(${lib}
+      PRIVATE ${LIBC_HERMETIC_TEST_COMPILE_OPTIONS} -ffreestanding -nostdlib -nostdlib++)
+endforeach()
 
 add_header_library(
   string_utils
Index: libc/cmake/modules/LLVMLibCTestRules.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCTestRules.cmake
+++ libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -179,7 +179,7 @@
   )
 
   # LibcUnitTest should not depend on anything in LINK_LIBRARIES.
-  list(APPEND link_libraries LibcTestMain LibcUnitTest)
+  list(APPEND link_libraries LibcUnitTestMain LibcUnitTest)
 
   target_link_libraries(${fq_build_target_name} PRIVATE ${link_libraries})
 
@@ -661,7 +661,7 @@
   target_link_libraries(
     ${fq_build_target_name}
     libc.startup.${LIBC_TARGET_OS}.crt1
-    LibcTestMain LibcHermeticTest
+    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}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149303.517363.patch
Type: text/x-patch
Size: 3198 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230426/b61c81bb/attachment.bin>


More information about the libc-commits mailing list