[libc-commits] [libc] [libc][cmake] Remove dependencies for bare-metal hermetic testing (PR #192242)
via libc-commits
libc-commits at lists.llvm.org
Wed Apr 15 05:03:04 PDT 2026
https://github.com/dcandler created https://github.com/llvm/llvm-project/pull/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.
>From 1f0d1d4a24570fb7c5d498783484d0e536aed6cf Mon Sep 17 00:00:00 2001
From: David Candler <david.candler at arm.com>
Date: Wed, 15 Apr 2026 12:34:34 +0100
Subject: [PATCH] [libc][cmake] Remove dependencies for bare-metal hermetic
testing
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.
---
libc/CMakeLists.txt | 2 ++
libc/test/CMakeLists.txt | 11 +++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
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