[libc-commits] [libc] [libc] Use `LIBC_COPT_PUBLIC_PACKAGING` for hermetic and integration tests. (PR #79319)
via libc-commits
libc-commits at lists.llvm.org
Wed Jan 24 08:20:48 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: None (lntue)
<details>
<summary>Changes</summary>
Currently all unit, hermetic, and integration tests are linked against `__internal__` entry points. This change switches the hermetic and integration tests to be linked against the public versions of the entry points.
---
Full diff: https://github.com/llvm/llvm-project/pull/79319.diff
3 Files Affected:
- (modified) libc/cmake/modules/LLVMLibCTestRules.cmake (+13-7)
- (modified) libc/test/integration/startup/CMakeLists.txt (+1-1)
- (modified) libc/test/src/math/differential_testing/CMakeLists.txt (+1-1)
``````````diff
diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 46ffc8316fc8227..3b1293e271f0f56 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -5,6 +5,7 @@
# Usage:
# get_object_files_for_test(<result var>
# <skipped_entrypoints_var>
+# <internal_obj>
# <target0> [<target1> ...])
#
# The list of object files is collected in <result_var>.
@@ -12,7 +13,8 @@
# set to a true value.
# targetN is either an "add_entrypoint_target" target or an
# "add_object_library" target.
-function(get_object_files_for_test result skipped_entrypoints_list)
+# If internal_obj is TRUE, then we collect `target.__internal__` for entry points.
+function(get_object_files_for_test result skipped_entrypoints_list internal_obj)
set(object_files "")
set(skipped_list "")
set(checked_list "")
@@ -49,7 +51,7 @@ function(get_object_files_for_test result skipped_entrypoints_list)
set(dep_skip "")
get_target_property(indirect_deps ${dep} "DEPS")
- get_object_files_for_test(dep_obj dep_skip ${indirect_deps})
+ get_object_files_for_test(dep_obj dep_skip ${internal_obj} ${indirect_deps})
if(${dep_type} STREQUAL ${OBJECT_LIBRARY_TARGET_TYPE})
get_target_property(dep_object_files ${dep} "OBJECT_FILES")
@@ -62,7 +64,11 @@ function(get_object_files_for_test result skipped_entrypoints_list)
list(APPEND dep_skip ${dep})
list(REMOVE_ITEM dep_obj ${dep})
endif()
- get_target_property(object_file_raw ${dep} "OBJECT_FILE_RAW")
+ if(${internal_obj})
+ get_target_property(object_file_raw ${dep} "OBJECT_FILE_RAW")
+ else()
+ get_target_property(object_file_raw ${dep} "OBJECT_FILE")
+ endif()
if(object_file_raw)
list(APPEND dep_obj ${object_file_raw})
endif()
@@ -130,7 +136,7 @@ function(create_libc_unittest fq_target_name)
libc.test.UnitTest.ErrnoSetterMatcher)
list(REMOVE_DUPLICATES fq_deps_list)
get_object_files_for_test(
- link_object_files skipped_entrypoints_list ${fq_deps_list})
+ link_object_files skipped_entrypoints_list TRUE ${fq_deps_list})
if(skipped_entrypoints_list)
# If a test is OS/target machine independent, it has to be skipped if the
# OS/target machine combination does not provide any dependent entrypoints.
@@ -388,7 +394,7 @@ function(add_libc_fuzzer target_name)
get_fq_target_name(${target_name} fq_target_name)
get_fq_deps_list(fq_deps_list ${LIBC_FUZZER_DEPENDS})
get_object_files_for_test(
- link_object_files skipped_entrypoints_list ${fq_deps_list})
+ link_object_files skipped_entrypoints_list TRUE ${fq_deps_list})
if(skipped_entrypoints_list)
if(LIBC_CMAKE_VERBOSE_LOGGING)
set(msg "Skipping fuzzer target ${fq_target_name} as it has missing deps: "
@@ -518,7 +524,7 @@ function(add_integration_test test_name)
# TODO: Instead of gathering internal object files from entrypoints,
# collect the object files with public names of entrypoints.
get_object_files_for_test(
- link_object_files skipped_entrypoints_list ${fq_deps_list})
+ link_object_files skipped_entrypoints_list FALSE ${fq_deps_list})
if(skipped_entrypoints_list)
if(LIBC_CMAKE_VERBOSE_LOGGING)
set(msg "Skipping unittest ${fq_target_name} as it has missing deps: "
@@ -702,7 +708,7 @@ function(add_libc_hermetic_test test_name)
# TODO: Instead of gathering internal object files from entrypoints,
# collect the object files with public names of entrypoints.
get_object_files_for_test(
- link_object_files skipped_entrypoints_list ${fq_deps_list})
+ link_object_files skipped_entrypoints_list FALSE ${fq_deps_list})
if(skipped_entrypoints_list)
set(msg "Skipping unittest ${fq_target_name} as it has missing deps: "
"${skipped_entrypoints_list}.")
diff --git a/libc/test/integration/startup/CMakeLists.txt b/libc/test/integration/startup/CMakeLists.txt
index fb5d6bc787cc261..8bdb841faf74f35 100644
--- a/libc/test/integration/startup/CMakeLists.txt
+++ b/libc/test/integration/startup/CMakeLists.txt
@@ -38,7 +38,7 @@ function(add_startup_test target_name)
if(ADD_STARTUP_TEST_DEPENDS)
get_fq_deps_list(fq_deps_list ${ADD_STARTUP_TEST_DEPENDS})
add_dependencies(${fq_target_name} ${fq_deps_list})
- get_object_files_for_test(link_object_files has_skipped_entrypoint_list ${fq_deps_list})
+ get_object_files_for_test(link_object_files has_skipped_entrypoint_list TRUE ${fq_deps_list})
target_link_libraries(${fq_target_name} ${link_object_files})
endif()
diff --git a/libc/test/src/math/differential_testing/CMakeLists.txt b/libc/test/src/math/differential_testing/CMakeLists.txt
index 72bc2f8fb16aaa0..41e1f2bcdca4945 100644
--- a/libc/test/src/math/differential_testing/CMakeLists.txt
+++ b/libc/test/src/math/differential_testing/CMakeLists.txt
@@ -27,7 +27,7 @@ function(add_diff_binary target_name)
get_fq_target_name(${target_name} fq_target_name)
get_fq_deps_list(fq_deps_list ${DIFF_DEPENDS})
get_object_files_for_test(
- link_object_files skipped_entrypoints_list ${fq_deps_list})
+ link_object_files skipped_entrypoints_list TRUE ${fq_deps_list})
if(skipped_entrypoints_list)
if(LIBC_CMAKE_VERBOSE_LOGGING)
set(msg "Will not build ${fq_target_name} as it has missing deps: "
``````````
</details>
https://github.com/llvm/llvm-project/pull/79319
More information about the libc-commits
mailing list