[libc-commits] [libc] 127487a - [libc] Add a new target named LibcHermeticTestMain.

Siva Chandra Reddy via libc-commits libc-commits at lists.llvm.org
Wed Apr 26 16:10:24 PDT 2023


Author: Siva Chandra Reddy
Date: 2023-04-26T23:10:16Z
New Revision: 127487aa4d74f9c63e3ec8c977b9e134f4216452

URL: https://github.com/llvm/llvm-project/commit/127487aa4d74f9c63e3ec8c977b9e134f4216452
DIFF: https://github.com/llvm/llvm-project/commit/127487aa4d74f9c63e3ec8c977b9e134f4216452.diff

LOG: [libc] Add a new target named LibcHermeticTestMain.

The existing LibcTestMain has been renamed to LibcUnitTestMain.
Hermetic tests are linked to LibcHermeticTestMain and unit tests are
linked to LibcUnitTestMain.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D149303

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index a059ac2134acb..51ed88211f9d6 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -179,7 +179,7 @@ function(create_libc_unittest fq_target_name)
   )
 
   # 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 @@ function(add_libc_hermetic_test test_name)
   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}

diff  --git a/libc/test/UnitTest/CMakeLists.txt b/libc/test/UnitTest/CMakeLists.txt
index 2f38c61594e90..c1f6d0d0750e8 100644
--- a/libc/test/UnitTest/CMakeLists.txt
+++ b/libc/test/UnitTest/CMakeLists.txt
@@ -15,24 +15,35 @@ endif()
 
 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 @@ foreach(lib LibcUnitTest LibcHermeticTest)
   )
 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


        


More information about the libc-commits mailing list