[libc-commits] [libc] 76d51b7 - [libc][cmake] Remove dependencies for bare-metal hermetic testing (#192242)

via libc-commits libc-commits at lists.llvm.org
Thu Apr 16 05:53:31 PDT 2026


Author: dcandler
Date: 2026-04-16T13:53:26+01:00
New Revision: 76d51b780dbbc491833e26db63a13c1f47a29c77

URL: https://github.com/llvm/llvm-project/commit/76d51b780dbbc491833e26db63a13c1f47a29c77
DIFF: https://github.com/llvm/llvm-project/commit/76d51b780dbbc491833e26db63a13c1f47a29c77.diff

LOG: [libc][cmake] Remove dependencies for bare-metal hermetic testing (#192242)

Unit tests can be disabled on bare-metal as they will fail to build. To
prevent the check-libc and check-libc-lit targets from always attempting
to build them, the dependencies are now set conditionally according to
the relevant CMake options.

Added: 
    

Modified: 
    libc/CMakeLists.txt
    libc/test/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 5b5fe981f2195..e796598e48924 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -272,6 +272,8 @@ endif()
 if(LIBC_TARGET_OS_IS_GPU)
   include(prepare_libc_gpu_build)
   set(LIBC_ENABLE_UNITTESTS OFF)
+elseif(LIBC_TARGET_OS_IS_BAREMETAL)
+  set(LIBC_ENABLE_UNITTESTS OFF)
 endif()
 
 include(LLVMLibCCheckMPFR)

diff  --git a/libc/test/CMakeLists.txt b/libc/test/CMakeLists.txt
index 5a154008c1867..dcfae50790c2e 100644
--- a/libc/test/CMakeLists.txt
+++ b/libc/test/CMakeLists.txt
@@ -1,7 +1,6 @@
 add_custom_target(check-libc)
 add_custom_target(libc-unit-tests)
 add_custom_target(libc-hermetic-tests)
-add_dependencies(check-libc libc-unit-tests libc-hermetic-tests)
 
 if (TARGET check-hdrgen)
   add_dependencies(check-libc check-hdrgen)
@@ -35,9 +34,17 @@ configure_lit_site_cfg(
 add_lit_testsuite(check-libc-lit
   "Running libc tests via lit"
   ${LIBC_BUILD_DIR}/test
-  DEPENDS libc-unit-tests-build libc-hermetic-tests-build libc-integration-tests-build libc_include_tests-build
 )
 
+if(LIBC_ENABLE_UNITTESTS AND NOT LIBC_TEST_HERMETIC_TEST_ONLY)
+  add_dependencies(check-libc libc-unit-tests)
+  add_dependencies(check-libc-lit libc-unit-tests-build)
+endif()
+if(LIBC_ENABLE_HERMETIC_TESTS AND NOT LIBC_TEST_UNIT_TEST_ONLY)
+  add_dependencies(check-libc libc-hermetic-tests)
+  add_dependencies(check-libc-lit libc-hermetic-tests-build)
+endif()
+
 add_subdirectory(UnitTest)
 
 if(LIBC_TARGET_OS_IS_GPU)


        


More information about the libc-commits mailing list