diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -163,7 +163,13 @@ if(LLVM_LIBC_FULL_BUILD) set(LIBC_TARGET libc) set(LIBC_COMPONENT libc) - set(LIBC_INSTALL_DEPENDS "libc;install-libc-headers;libc-startup") + 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() set(LIBC_INSTALL_TARGET install-libc) if(LIBC_TARGET_ARCHITECTURE_IS_GPU) set(LIBC_ARCHIVE_NAME cgpu) @@ -173,7 +179,7 @@ else() set(LIBC_TARGET llvmlibc) set(LIBC_COMPONENT llvmlibc) - set(LIBC_INSTALL_DEPENDS llvmlibc) + set(LIBC_INSTALL_DEPENDS install-libc-static-archives) set(LIBC_INSTALL_TARGET install-llvmlibc) set(LIBC_ARCHIVE_NAME llvmlibc) endif() diff --git a/libc/lib/CMakeLists.txt b/libc/lib/CMakeLists.txt --- a/libc/lib/CMakeLists.txt +++ b/libc/lib/CMakeLists.txt @@ -9,14 +9,23 @@ ARCHIVE_OUTPUT_NAME ${LIBC_ARCHIVE_NAME} ) -if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR) - set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}) +if(LIBC_TARGET_TRIPLE) + set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LIBC_TARGET_TRIPLE}) +elseif(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR) + set(LIBC_INSTALL_LIBRARY_DIR + lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}) else() set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}) endif() install( TARGETS ${LIBC_TARGET} - ARCHIVE DESTINATION "${LIBC_INSTALL_LIBRARY_DIR}" - COMPONENT ${LIBC_COMPONENT} + ARCHIVE DESTINATION ${LIBC_INSTALL_LIBRARY_DIR} + COMPONENT libc-static-archives +) + +add_llvm_install_targets( + install-libc-static-archives + DEPENDS ${LIBC_TARGET} + COMPONENT libc-static-archives )