Index: libc/CMakeLists.txt =================================================================== --- libc/CMakeLists.txt +++ libc/CMakeLists.txt @@ -99,8 +99,23 @@ include("${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/headers.txt") endif() +if(LLVM_LIBC_FULL_BUILD) + # We need to set up hdrgen first since other targets depend on it. + add_subdirectory(utils/LibcTableGenUtil) + add_subdirectory(utils/HdrGen) +endif() + +define_property(GLOBAL PROPERTY TARGET_LLVMLIBC_USED_ENTRYPOINTS BRIEF_DOCS "List of targets" FULL_DOCS "List of targets") +set_property(GLOBAL PROPERTY TARGET_LLVMLIBC_USED_ENTRYPOINTS "") + +add_subdirectory(config) +add_subdirectory(src) +add_subdirectory(utils) + +get_property(libc_dependencies GLOBAL PROPERTY TARGET_LLVMLIBC_USED_ENTRYPOINTS) + set(TARGET_ENTRYPOINT_NAME_LIST "") -foreach(entrypoint IN LISTS TARGET_LLVMLIBC_ENTRYPOINTS) +foreach(entrypoint IN LISTS libc_dependencies) string(FIND ${entrypoint} "." last_dot_loc REVERSE) if(${last_dot_loc} EQUAL -1) message(FATAL "Invalid entrypoint target name ${entrypoint}; Expected a '.' " @@ -111,16 +126,7 @@ list(APPEND TARGET_ENTRYPOINT_NAME_LIST ${entrypoint_name}) endforeach() -if(LLVM_LIBC_FULL_BUILD) - # We need to set up hdrgen first since other targets depend on it. - add_subdirectory(utils/LibcTableGenUtil) - add_subdirectory(utils/HdrGen) -endif() - add_subdirectory(include) -add_subdirectory(config) -add_subdirectory(src) -add_subdirectory(utils) if(LLVM_LIBC_FULL_BUILD) # The loader can potentially depend on the library components so add it Index: libc/cmake/modules/LLVMLibCObjectRules.cmake =================================================================== --- libc/cmake/modules/LLVMLibCObjectRules.cmake +++ libc/cmake/modules/LLVMLibCObjectRules.cmake @@ -62,6 +62,17 @@ ) endfunction(add_object_library) +function(_target_matches_glob output_var target) + foreach(glob_expr IN LISTS ARGN) + if(${target} MATCHES "^${glob_expr}$") + set(${output_var} TRUE PARENT_SCOPE) + return() + endif() + endforeach() + + set(${output_var} FALSE PARENT_SCOPE) +endfunction() + set(ENTRYPOINT_OBJ_TARGET_TYPE "ENTRYPOINT_OBJ") # A rule for entrypoint object targets. @@ -91,21 +102,10 @@ set(entrypoint_name ${ADD_ENTRYPOINT_OBJ_NAME}) endif() - list(FIND TARGET_ENTRYPOINT_NAME_LIST ${entrypoint_name} entrypoint_name_index) - if(${entrypoint_name_index} EQUAL -1) - add_custom_target(${fq_target_name}) - set_target_properties( - ${fq_target_name} - PROPERTIES - "ENTRYPOINT_NAME" ${entrypoint_name} - "TARGET_TYPE" ${ENTRYPOINT_OBJ_TARGET_TYPE} - "OBJECT_FILE" "" - "OBJECT_FILE_RAW" "" - "DEPS" "" - "SKIPPED" "YES" - ) - message(STATUS "Skipping libc entrypoint ${fq_target_name}.") - return() + _target_matches_glob(include_target ${fq_target_name} ${TARGET_LLVMLIBC_ENTRYPOINTS}) + _target_matches_glob(exclude_target ${fq_target_name} ${TARGET_LIBC_OMIT_ENTRYPOINTS}) + if(${include_target} AND NOT ${exclude_target}) + set_property(GLOBAL APPEND PROPERTY TARGET_LLVMLIBC_USED_ENTRYPOINTS ${fq_target_name}) endif() if(ADD_ENTRYPOINT_OBJ_ALIAS) @@ -286,6 +286,8 @@ "DEPS" "${ADD_ENTRYPOINT_EXT_DEPENDS}" ) + set_property(GLOBAL APPEND PROPERTY TARGET_LLVMLIBC_USED_ENTRYPOINTS ${fq_target_name}) + endfunction(add_entrypoint_external) # Rule build a redirector object file. Index: libc/cmake/modules/LLVMLibCTestRules.cmake =================================================================== --- libc/cmake/modules/LLVMLibCTestRules.cmake +++ libc/cmake/modules/LLVMLibCTestRules.cmake @@ -29,8 +29,9 @@ 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) + get_property(libc_dependencies GLOBAL PROPERTY TARGET_LLVMLIBC_USED_ENTRYPOINTS) + list(FIND libc_dependencies ${dep} entrypoint_name_index) + if(${entrypoint_name_index} EQUAL -1) list(APPEND skipped_list ${dep}) continue() endif() Index: libc/config/linux/x86_64/entrypoints.txt =================================================================== --- libc/config/linux/x86_64/entrypoints.txt +++ libc/config/linux/x86_64/entrypoints.txt @@ -1,21 +1,6 @@ set(TARGET_LIBC_ENTRYPOINTS # ctype.h entrypoints - libc.src.ctype.isalnum - libc.src.ctype.isalpha - libc.src.ctype.isascii - libc.src.ctype.isblank - libc.src.ctype.iscntrl - libc.src.ctype.isdigit - libc.src.ctype.isgraph - libc.src.ctype.islower - libc.src.ctype.isprint - libc.src.ctype.ispunct - libc.src.ctype.isspace - libc.src.ctype.isupper - libc.src.ctype.isxdigit - libc.src.ctype.toascii - libc.src.ctype.tolower - libc.src.ctype.toupper + libc.src.ctype.* # errno.h entrypoints libc.src.errno.__errno_location Index: libc/lib/CMakeLists.txt =================================================================== --- libc/lib/CMakeLists.txt +++ libc/lib/CMakeLists.txt @@ -1,7 +1,9 @@ +get_property(libc_dependencies GLOBAL PROPERTY TARGET_LLVMLIBC_USED_ENTRYPOINTS) + add_entrypoint_library( llvmlibc DEPENDS - ${TARGET_LLVMLIBC_ENTRYPOINTS} + ${libc_dependencies} ) if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR) Index: libc/test/src/CMakeLists.txt =================================================================== --- libc/test/src/CMakeLists.txt +++ libc/test/src/CMakeLists.txt @@ -50,8 +50,10 @@ set(public_test ${CMAKE_CURRENT_BINARY_DIR}/public_integration_test.cpp) +get_property(libc_dependencies GLOBAL PROPERTY TARGET_LLVMLIBC_USED_ENTRYPOINTS) + set(entrypoints_name_list "") -foreach(entry IN LISTS TARGET_LLVMLIBC_ENTRYPOINTS) +foreach(entry IN LISTS libc_dependencies) get_target_property(entry_name ${entry} "ENTRYPOINT_NAME") list(APPEND entrypoints_name_list ${entry_name}) endforeach() Index: libc/utils/HdrGen/Main.cpp =================================================================== --- libc/utils/HdrGen/Main.cpp +++ libc/utils/HdrGen/Main.cpp @@ -27,8 +27,7 @@ llvm::cl::list EntrypointNamesOption( "e", llvm::cl::value_desc(""), llvm::cl::desc( - "Each --e is one entrypoint (generated from entrypoints.txt)"), - llvm::cl::OneOrMore); + "Each --e is one entrypoint (generated from entrypoints.txt)")); llvm::cl::list ReplacementValues( "args", llvm::cl::desc("Command separated = pairs."), llvm::cl::value_desc("[,name=value]"));