[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 16:10:26 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG127487aa4d74: [libc] Add a new target named LibcHermeticTestMain. (authored by sivachandra).

Repository:
  rG LLVM Github Monorepo

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

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.517373.patch
Type: text/x-patch
Size: 3198 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230426/90d16ca9/attachment.bin>


More information about the libc-commits mailing list