Skip to content

[libc][NFC] Make entrypoint alias targets real library targets. #66044

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
merged 2 commits into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions libc/cmake/modules/LLVMLibCObjectRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ function(create_entrypoint_object fq_target_name)
return()
endif()

set(internal_target_name ${fq_target_name}.__internal__)

if(ADD_ENTRYPOINT_OBJ_ALIAS)
# Alias targets help one add aliases to other entrypoint object targets.
# One can use alias targets setup OS/machine independent entrypoint targets.
Expand Down Expand Up @@ -586,10 +588,22 @@ function(create_entrypoint_object fq_target_name)
message(FATAL_ERROR "The aliasee of an entrypoint alias should be an entrypoint.")
endif()

add_custom_target(${fq_target_name})
add_dependencies(${fq_target_name} ${fq_dep_name})
get_target_property(object_file ${fq_dep_name} "OBJECT_FILE")
get_target_property(object_file_raw ${fq_dep_name} "OBJECT_FILE_RAW")
add_library(
${internal_target_name}
EXCLUDE_FROM_ALL
OBJECT
${object_file_raw}
)
add_dependencies(${internal_target_name} ${fq_dep_name})
add_library(
${fq_target_name}
EXCLUDE_FROM_ALL
OBJECT
${object_file}
)
add_dependencies(${fq_target_name} ${fq_dep_name} ${internal_target_name})
set_target_properties(
${fq_target_name}
PROPERTIES
Expand Down Expand Up @@ -619,7 +633,6 @@ function(create_entrypoint_object fq_target_name)
"${ADD_ENTRYPOINT_OBJ_FLAGS}"
${ADD_ENTRYPOINT_OBJ_COMPILE_OPTIONS}
)
set(internal_target_name ${fq_target_name}.__internal__)
set(include_dirs ${LIBC_SOURCE_DIR} ${LIBC_INCLUDE_DIR})
get_fq_deps_list(fq_deps_list ${ADD_ENTRYPOINT_OBJ_DEPENDS})
set(full_deps_list ${fq_deps_list} libc.src.__support.common)
Expand Down