[libc-commits] [PATCH] D150698: [libc] Remove *TestMain libraries and combine them with the main test libraries.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue May 16 11:19:56 PDT 2023


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

There are not tests currently which use the main test framework but not
the `main` function from LibcTestMain.cpp. So, this change essentially
simplifies by merging the *TestMain libraries with the main test
libraries.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150698

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
@@ -1,9 +1,10 @@
 set(libc_test_srcs_common
-  Test.h
-  LibcTest.cpp
   CmakeFilePath.cpp
-  LibcTest.h
+  LibcTest.cpp
+  LibcTestMain.cpp
   TestLogger.cpp
+  LibcTest.h
+  Test.h
   TestLogger.h
 )
 
@@ -36,23 +37,7 @@
   HermeticTestUtils.cpp
 )
 
-add_library(
-  LibcUnitTestMain
-  ${library_type}
-  EXCLUDE_FROM_ALL
-  LibcTestMain.cpp
-)
-add_dependencies(LibcUnitTestMain LibcUnitTest)
-
-add_library(
-  LibcHermeticTestMain
-  ${library_type}
-  EXCLUDE_FROM_ALL
-  LibcTestMain.cpp
-)
-add_dependencies(LibcHermeticTestMain LibcHermeticTest)
-
-foreach(lib LibcUnitTest LibcUnitTestMain LibcHermeticTest LibcHermeticTestMain)
+foreach(lib LibcUnitTest LibcHermeticTest)
   target_include_directories(${lib} PUBLIC ${LIBC_SOURCE_DIR})
   target_compile_options(${lib} PRIVATE -fno-exceptions -fno-rtti)
   add_dependencies(${lib}
@@ -65,11 +50,9 @@
   )
 endforeach()
 
-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()
+target_include_directories(LibcHermeticTest PRIVATE ${LIBC_BUILD_DIR}/include)
+target_compile_options(LibcHermeticTest
+    PRIVATE ${LIBC_HERMETIC_TEST_COMPILE_OPTIONS} -ffreestanding -nostdlib -nostdlib++)
 
 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 LibcUnitTestMain LibcUnitTest)
+  list(APPEND link_libraries LibcUnitTest)
 
   target_link_libraries(${fq_build_target_name} PRIVATE ${link_libraries})
 
@@ -669,7 +669,7 @@
     PRIVATE
       ${HERMETIC_TEST_LINK_LIBRARIES}
       libc.startup.${LIBC_TARGET_OS}.crt1
-      LibcHermeticTestMain LibcHermeticTest
+      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: D150698.522721.patch
Type: text/x-patch
Size: 2474 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230516/0c1c7fd4/attachment.bin>


More information about the libc-commits mailing list