[libc-commits] [libc] 2353b52 - [libc] Fix some missing features from the hermetic test support
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Tue May 2 07:40:33 PDT 2023
Author: Joseph Huber
Date: 2023-05-02T09:40:24-05:00
New Revision: 2353b52eae71ffa3993d21f0bed0c571cf2e0c79
URL: https://github.com/llvm/llvm-project/commit/2353b52eae71ffa3993d21f0bed0c571cf2e0c79
DIFF: https://github.com/llvm/llvm-project/commit/2353b52eae71ffa3993d21f0bed0c571cf2e0c79.diff
LOG: [libc] Fix some missing features from the hermetic test support
This patch addresses some of the flags and features that are currently
missing from the hermetic test support. This mostly just fixes the
`add_libc_test` option failing to find a few dependencies or missing
arguments from the previous unit test support.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D149629
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 51ed88211f9d6..a99274ce5ce36 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -568,6 +568,7 @@ endif()
# ARGS <list of command line arguments to be passed to the test>
# ENV <list of environment variables to set before running the test>
# COMPILE_OPTIONS <list of special compile options for the test>
+# LINK_LIBRARIES <list of linking libraries for this target>
# LOADER_ARGS <list of special args to loaders (like the GPU loader)>
# )
function(add_libc_hermetic_test test_name)
@@ -579,7 +580,7 @@ function(add_libc_hermetic_test test_name)
"HERMETIC_TEST"
"" # No optional arguments
"SUITE" # Single value arguments
- "SRCS;HDRS;DEPENDS;ARGS;ENV;COMPILE_OPTIONS;LOADER_ARGS" # Multi-value arguments
+ "SRCS;HDRS;DEPENDS;ARGS;ENV;COMPILE_OPTIONS;LINK_LIBRARIES;LOADER_ARGS" # Multi-value arguments
${ARGN}
)
@@ -660,13 +661,15 @@ function(add_libc_hermetic_test test_name)
target_link_options(${fq_build_target_name} PRIVATE -nostdlib -static)
target_link_libraries(
${fq_build_target_name}
- libc.startup.${LIBC_TARGET_OS}.crt1
- LibcHermeticTestMain LibcHermeticTest
- # The NVIDIA 'nvlink' linker does not currently support static libraries.
- $<$<NOT:$<BOOL:${LIBC_GPU_TARGET_ARCHITECTURE_IS_NVPTX}>>:${fq_target_name}.__libc__>)
+ PRIVATE
+ ${HERMETIC_TEST_LINK_LIBRARIES}
+ libc.startup.${LIBC_TARGET_OS}.crt1
+ 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}
LibcHermeticTest
- ${HERMETIC_TEST_DEPENDS})
+ ${fq_deps_list})
# Tests on the GPU require an external loader utility to launch the kernel.
if(TARGET libc.utils.gpu.loader)
diff --git a/libc/test/UnitTest/CMakeLists.txt b/libc/test/UnitTest/CMakeLists.txt
index c1f6d0d0750e8..0335a8199fc26 100644
--- a/libc/test/UnitTest/CMakeLists.txt
+++ b/libc/test/UnitTest/CMakeLists.txt
@@ -77,8 +77,6 @@ add_library(
RoundingModeUtils.cpp
RoundingModeUtils.h
)
-target_include_directories(LibcFPTestHelpers PUBLIC ${LIBC_SOURCE_DIR})
-target_link_libraries(LibcFPTestHelpers LibcUnitTest)
add_dependencies(
LibcFPTestHelpers
LibcUnitTest
@@ -93,8 +91,6 @@ add_library(
MemoryMatcher.h
MemoryMatcher.cpp
)
-target_include_directories(LibcMemoryHelpers PUBLIC ${LIBC_SOURCE_DIR})
-target_link_libraries(LibcMemoryHelpers LibcUnitTest)
add_dependencies(
LibcMemoryHelpers
LibcUnitTest
@@ -106,8 +102,6 @@ add_library(
PrintfMatcher.h
PrintfMatcher.cpp
)
-target_include_directories(LibcPrintfHelpers PUBLIC ${LIBC_SOURCE_DIR})
-target_link_libraries(LibcPrintfHelpers LibcUnitTest)
add_dependencies(
LibcPrintfHelpers
LibcUnitTest
@@ -121,8 +115,6 @@ add_library(
ScanfMatcher.h
ScanfMatcher.cpp
)
-target_include_directories(LibcScanfHelpers PUBLIC ${LIBC_SOURCE_DIR})
-target_link_libraries(LibcScanfHelpers LibcUnitTest)
add_dependencies(
LibcScanfHelpers
LibcUnitTest
@@ -130,3 +122,9 @@ add_dependencies(
libc.src.stdio.scanf_core.core_structs
libc.test.UnitTest.string_utils
)
+
+foreach(lib LibcFPTestHelpers LibcMemoryHelpers LibcPrintfHelpers LibcScanfHelpers)
+ target_include_directories(${lib} PUBLIC ${LIBC_SOURCE_DIR})
+ target_compile_options(${lib} PRIVATE -fno-exceptions -fno-rtti)
+target_link_libraries(${lib} LibcUnitTest)
+endforeach()
More information about the libc-commits
mailing list