Skip to content

[libc] Redo the install targets #78795

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 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
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
28 changes: 0 additions & 28 deletions libc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -348,19 +348,6 @@ foreach(entrypoint IN LISTS TARGET_LLVMLIBC_ENTRYPOINTS)
list(APPEND TARGET_ENTRYPOINT_NAME_LIST ${entrypoint_name})
endforeach()

set(LIBC_INSTALL_DEPENDS)
if(LLVM_LIBC_FULL_BUILD)
set(LIBC_INSTALL_DEPENDS "install-libc-static-archives;install-libc-headers")
if(NOT LIBC_TARGET_OS_IS_BAREMETAL)
# For now we will disable libc-startup installation for baremetal. The
# correct way to do it would be to make a hookable startup for baremetal
# and install it as part of the libc installation.
list(APPEND LIBC_INSTALL_DEPENDS "libc-startup")
endif()
else()
set(LIBC_INSTALL_DEPENDS install-libc-static-archives)
endif()

add_subdirectory(include)
add_subdirectory(config)
add_subdirectory(src)
Expand Down Expand Up @@ -388,18 +375,3 @@ endif()
if (LIBC_INCLUDE_DOCS)
add_subdirectory(docs)
endif()


if(LLVM_LIBC_FULL_BUILD)
add_llvm_install_targets(
install-libc-headers
DEPENDS libc-headers
COMPONENT libc-headers
)
endif()

add_llvm_install_targets(
install-libc
DEPENDS ${LIBC_INSTALL_DEPENDS}
COMPONENT libc
)
10 changes: 10 additions & 0 deletions libc/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -606,3 +606,13 @@ foreach(target IN LISTS all_install_header_targets)
COMPONENT libc-headers)
endif()
endforeach()

if(LLVM_LIBC_FULL_BUILD)
add_custom_target(install-libc-headers
DEPENDS libc-headers
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=libc-headers
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
# Stripping is a no-op for headers
add_custom_target(install-libc-headers-stripped DEPENDS install-libc-headers)
endif()
36 changes: 30 additions & 6 deletions libc/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ foreach(archive IN ZIP_LISTS
PROPERTIES
ARCHIVE_OUTPUT_NAME ${archive_0}
)
if(LLVM_LIBC_FULL_BUILD)
target_link_libraries(${archive_1} PUBLIC libc-headers)
endif()
list(APPEND added_archive_targets ${archive_1})
endforeach()

Expand All @@ -48,11 +51,32 @@ endif()
install(
TARGETS ${added_archive_targets}
ARCHIVE DESTINATION ${LIBC_INSTALL_LIBRARY_DIR}
COMPONENT libc-static-archives
COMPONENT libc
)

add_llvm_install_targets(
install-libc-static-archives
DEPENDS ${added_archive_targets}
COMPONENT libc-static-archives
)
if(NOT LIBC_TARGET_OS_IS_BAREMETAL)
# For now we will disable libc-startup installation for baremetal. The
# correct way to do it would be to make a hookable startup for baremetal
# and install it as part of the libc installation.
set(startup_target "libc-startup")
endif()

if(LLVM_LIBC_FULL_BUILD)
set(header_install_target install-libc-headers)
endif()

add_custom_target(install-libc
DEPENDS ${added_archive_targets}
${startup_target}
${header_install_target}
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=libc
-P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
add_custom_target(install-libc-stripped
DEPENDS ${added_archive_targets}
${startup_target}
${header_install_target}
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=libc
-DCMAKE_INSTALL_DO_STRIP=1
-P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
2 changes: 1 addition & 1 deletion libc/utils/gpu/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ target_compile_definitions(llvmlibc_rpc_server PUBLIC
# Install the server and associated header.
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/rpc_server.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gpu-none-llvm/
COMPONENT libc)
COMPONENT libc-headers)
install(TARGETS llvmlibc_rpc_server
ARCHIVE DESTINATION "lib${LLVM_LIBDIR_SUFFIX}"
COMPONENT libc)