-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc] Remove recursion in get_object_files_for_test to improve build time. #72351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-libc Author: None (lntue) ChangesFull diff: https://github.com/llvm/llvm-project/pull/72351.diff 1 Files Affected:
diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index f7ca6a2e7021141..7484daaa22db4d4 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -15,48 +15,60 @@
function(get_object_files_for_test result skipped_entrypoints_list)
set(object_files "")
set(skipped_list "")
- foreach(dep IN LISTS ARGN)
- if (NOT TARGET ${dep})
- # Skip any tests whose dependencies have not been defined.
- list(APPEND skipped_list ${dep})
- continue()
- endif()
- get_target_property(dep_type ${dep} "TARGET_TYPE")
- if(NOT dep_type)
- # Target for which TARGET_TYPE property is not set do not
- # provide any object files.
- continue()
- endif()
+ set(checked_list "")
+ set(unchecked_list "${ARGN}")
+ list(REMOVE_DUPLICATES unchecked_list)
+ list(LENGTH unchecked_list length)
- if(${dep_type} STREQUAL ${OBJECT_LIBRARY_TARGET_TYPE})
- get_target_property(dep_object_files ${dep} "OBJECT_FILES")
- if(dep_object_files)
- list(APPEND object_files ${dep_object_files})
- endif()
- elseif(${dep_type} STREQUAL ${ENTRYPOINT_OBJ_TARGET_TYPE})
- get_target_property(is_skipped ${dep} "SKIPPED")
- if(is_skipped)
+ while(length)
+ set(indirect_list "")
+
+ foreach(dep IN LISTS unchecked_list)
+ if (NOT TARGET ${dep})
+ # Skip any tests whose dependencies have not been defined.
list(APPEND skipped_list ${dep})
continue()
endif()
- get_target_property(object_file_raw ${dep} "OBJECT_FILE_RAW")
- if(object_file_raw)
- list(APPEND object_files ${object_file_raw})
+ get_target_property(dep_type ${dep} "TARGET_TYPE")
+ if(NOT dep_type)
+ # Target for which TARGET_TYPE property is not set do not
+ # provide any object files.
+ continue()
endif()
- elseif(${dep_type} STREQUAL ${ENTRYPOINT_OBJ_VENDOR_TARGET_TYPE})
- # We skip tests for all externally implemented entrypoints.
- list(APPEND skipped_list ${dep})
- continue()
- endif()
- get_target_property(indirect_deps ${dep} "DEPS")
- get_object_files_for_test(
- indirect_objfiles indirect_skipped_list ${indirect_deps})
- list(APPEND object_files ${indirect_objfiles})
- if(indirect_skipped_list)
- list(APPEND skipped_list ${indirect_skipped_list})
- endif()
- endforeach(dep)
+ if(${dep_type} STREQUAL ${OBJECT_LIBRARY_TARGET_TYPE})
+ get_target_property(dep_object_files ${dep} "OBJECT_FILES")
+ if(dep_object_files)
+ list(APPEND object_files ${dep_object_files})
+ endif()
+ elseif(${dep_type} STREQUAL ${ENTRYPOINT_OBJ_TARGET_TYPE})
+ get_target_property(is_skipped ${dep} "SKIPPED")
+ if(is_skipped)
+ list(APPEND skipped_list ${dep})
+ continue()
+ endif()
+ get_target_property(object_file_raw ${dep} "OBJECT_FILE_RAW")
+ if(object_file_raw)
+ list(APPEND object_files ${object_file_raw})
+ endif()
+ elseif(${dep_type} STREQUAL ${ENTRYPOINT_OBJ_VENDOR_TARGET_TYPE})
+ # We skip tests for all externally implemented entrypoints.
+ list(APPEND skipped_list ${dep})
+ continue()
+ endif()
+
+ get_target_property(indirect_deps ${dep} "DEPS")
+ list(APPEND indirect_list "${indirect_deps}")
+ endforeach(dep)
+
+ # Only add new indirect dependencies to check.
+ list(APPEND checked_list "${unchecked_list}")
+ list(REMOVE_DUPLICATES indirect_list)
+ list(REMOVE_ITEM indirect_list checked_list)
+ set(unchecked_list "${indirect_list}")
+ list(LENGTH unchecked_list length)
+ endwhile()
+
list(REMOVE_DUPLICATES object_files)
set(${result} ${object_files} PARENT_SCOPE)
list(REMOVE_DUPLICATES skipped_list)
|
gchatelet
approved these changes
Nov 16, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Only a few nits to get comments short and consistent,
sr-tream
pushed a commit
to sr-tream/llvm-project
that referenced
this pull request
Nov 20, 2023
zahiraam
pushed a commit
to zahiraam/llvm-project
that referenced
this pull request
Nov 20, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.