Skip to content

Commit d86f998

Browse files
committed
Update get_object_files_for_test caching to take internal_obj into consideration.
1 parent 49ba302 commit d86f998

File tree

1 file changed

+62
-7
lines changed

1 file changed

+62
-7
lines changed

libc/cmake/modules/LLVMLibCTestRules.cmake

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ function(get_object_files_for_test result skipped_entrypoints_list internal_obj)
1919
set(skipped_list "")
2020
set(checked_list "")
2121
set(unchecked_list "${ARGN}")
22+
23+
set(check_obj_for_tests "CHECK_OBJ_FOR_TESTS_${internal_obj}")
24+
set(object_files_for_tests "OBJECT_FILES_FOR_TESTS_${internal_obj}")
25+
set(skipped_list_for_tests "SKIPPED_LIST_FOR_TESTS_${internal_obj}")
26+
2227
list(REMOVE_DUPLICATES unchecked_list)
2328

2429
foreach(dep IN LISTS unchecked_list)
@@ -39,12 +44,12 @@ function(get_object_files_for_test result skipped_entrypoints_list internal_obj)
3944
continue()
4045
endif()
4146

42-
get_target_property(dep_checked ${dep} "CHECK_OBJ_FOR_TESTS")
47+
get_target_property(dep_checked ${dep} ${check_obj_for_tests})
4348

4449
if(dep_checked)
4550
# Target full dependency has already been checked. Just use the results.
46-
get_target_property(dep_obj ${dep} "OBJECT_FILES_FOR_TESTS")
47-
get_target_property(dep_skip ${dep} "SKIPPED_LIST_FOR_TESTS")
51+
get_target_property(dep_obj ${dep} ${object_files_for_tests})
52+
get_target_property(dep_skip ${dep} ${skipped_list_for_tests})
4853
else()
4954
# Target full dependency hasn't been checked. Recursively check its DEPS.
5055
set(dep_obj "${dep}")
@@ -79,9 +84,9 @@ function(get_object_files_for_test result skipped_entrypoints_list internal_obj)
7984
endif()
8085

8186
set_target_properties(${dep} PROPERTIES
82-
OBJECT_FILES_FOR_TESTS "${dep_obj}"
83-
SKIPPED_LIST_FOR_TESTS "${dep_skip}"
84-
CHECK_OBJ_FOR_TESTS "YES"
87+
"${object_files_for_tests}" "${dep_obj}"
88+
"${skipped_list_for_tests}" "${dep_skip}"
89+
"${check_obj_for_tests}" "YES"
8590
)
8691

8792
endif()
@@ -173,6 +178,15 @@ function(create_libc_unittest fq_target_name)
173178
return()
174179
endif()
175180

181+
if(SHOW_INTERMEDIATE_OBJECTS)
182+
message(STATUS "Adding unit test ${fq_target_name}")
183+
if(${SHOW_INTERMEDIATE_OBJECTS} STREQUAL "DEPS")
184+
foreach(dep IN LISTS LIBC_UNITTEST_DEPENDS)
185+
message(STATUS " ${fq_target_name} depends on ${dep}")
186+
endforeach()
187+
endif()
188+
endif()
189+
176190
if(LIBC_UNITTEST_NO_RUN_POSTBUILD)
177191
set(fq_build_target_name ${fq_target_name})
178192
else()
@@ -499,13 +513,24 @@ function(add_integration_test test_name)
499513
get_fq_target_name(${test_name}.libc fq_libc_target_name)
500514

501515
get_fq_deps_list(fq_deps_list ${INTEGRATION_TEST_DEPENDS})
516+
517+
if(SHOW_INTERMEDIATE_OBJECTS)
518+
message(STATUS "Adding integration test ${fq_target_name}")
519+
if(${SHOW_INTERMEDIATE_OBJECTS} STREQUAL "DEPS")
520+
foreach(dep IN LISTS fq_deps_list)
521+
message(STATUS " ${fq_target_name} depends on ${dep}")
522+
endforeach()
523+
endif()
524+
endif()
525+
502526
list(APPEND fq_deps_list
503527
# All integration tests use the operating system's startup object with the
504528
# integration test object and need to inherit the same dependencies.
505529
libc.startup.${LIBC_TARGET_OS}.crt1
506530
libc.test.IntegrationTest.test
507531
# We always add the memory functions objects. This is because the
508532
# compiler's codegen can emit calls to the C memory functions.
533+
libc.src.stdlib.atexit
509534
libc.src.string.bcmp
510535
libc.src.string.bzero
511536
libc.src.string.memcmp
@@ -526,6 +551,16 @@ function(add_integration_test test_name)
526551
# collect the object files with public names of entrypoints.
527552
get_object_files_for_test(
528553
link_object_files skipped_entrypoints_list FALSE ${fq_deps_list})
554+
555+
if(SHOW_INTERMEDIATE_OBJECTS)
556+
message(STATUS "Get objects for test ${fq_target_name}")
557+
if(${SHOW_INTERMEDIATE_OBJECTS} STREQUAL "DEPS")
558+
foreach(dep IN LISTS link_object_files)
559+
message(STATUS " ${fq_target_name} need object ${dep}")
560+
endforeach()
561+
endif()
562+
endif()
563+
529564
if(skipped_entrypoints_list)
530565
if(LIBC_CMAKE_VERBOSE_LOGGING)
531566
set(msg "Skipping integration test ${fq_target_name} as it has missing deps: "
@@ -678,6 +713,16 @@ function(add_libc_hermetic_test test_name)
678713
get_fq_target_name(${test_name}.libc fq_libc_target_name)
679714

680715
get_fq_deps_list(fq_deps_list ${HERMETIC_TEST_DEPENDS})
716+
717+
if(SHOW_INTERMEDIATE_OBJECTS)
718+
message(STATUS "Adding hermetic test ${fq_target_name}")
719+
if(${SHOW_INTERMEDIATE_OBJECTS} STREQUAL "DEPS")
720+
foreach(dep IN LISTS fq_deps_list)
721+
message(STATUS " ${fq_target_name} depends on ${dep}")
722+
endforeach()
723+
endif()
724+
endif()
725+
681726
list(APPEND fq_deps_list
682727
# Hermetic tests use the platform's startup object. So, their deps also
683728
# have to be collected.
@@ -710,7 +755,17 @@ function(add_libc_hermetic_test test_name)
710755
# collect the object files with public names of entrypoints.
711756
get_object_files_for_test(
712757
link_object_files skipped_entrypoints_list FALSE ${fq_deps_list})
713-
if(skipped_entrypoints_list)
758+
759+
if(SHOW_INTERMEDIATE_OBJECTS)
760+
message(STATUS "Get objects for test ${fq_target_name}")
761+
if(${SHOW_INTERMEDIATE_OBJECTS} STREQUAL "DEPS")
762+
foreach(dep IN LISTS link_object_files)
763+
message(STATUS " ${fq_target_name} need object ${dep}")
764+
endforeach()
765+
endif()
766+
endif()
767+
768+
if(skipped_entrypoints_list)
714769
set(msg "Skipping hermetic test ${fq_target_name} as it has missing deps: "
715770
"${skipped_entrypoints_list}.")
716771
message(STATUS ${msg})

0 commit comments

Comments
 (0)