Skip to content

Commit 049e142

Browse files
authored
[libc] Fix startup utilities failing to install in full build mode (#82522)
Summary: Currently, doing `ninja install` will fail in fullbuild mode due to the startup utilities not being built by default. This was hidden previously by the fact that if tests were run, it would build the startup utilities and thus they would be present. This patch solves this issue by making the `libc-startup` target a dependncy on the final library. Furthermore we simply factor out the library install directory into the base CMake directory next to the include directory handling. This change makes the `crt` files get installed in `lib/x86_64-unknown-linu-gnu` instead of just `lib`. This fixes an error I had where doing a runtimes failed to install its libraries because the install step always errored.
1 parent 828bf13 commit 049e142

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

libc/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,15 @@ else()
225225
set(LIBC_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR})
226226
endif()
227227

228+
if(LIBC_TARGET_TRIPLE)
229+
set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LIBC_TARGET_TRIPLE})
230+
elseif(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT LIBC_GPU_BUILD)
231+
set(LIBC_INSTALL_LIBRARY_DIR
232+
lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
233+
else()
234+
set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX})
235+
endif()
236+
228237
if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
229238
include(prepare_libc_gpu_build)
230239
set(LIBC_ENABLE_UNITTESTS OFF)

libc/lib/CMakeLists.txt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,13 @@ foreach(archive IN ZIP_LISTS
3535
)
3636
if(LLVM_LIBC_FULL_BUILD)
3737
target_link_libraries(${archive_1} PUBLIC libc-headers)
38+
if(TARGET libc-startup)
39+
add_dependencies(${archive_1} libc-startup)
40+
endif()
3841
endif()
3942
list(APPEND added_archive_targets ${archive_1})
4043
endforeach()
4144

42-
if(LIBC_TARGET_TRIPLE)
43-
set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LIBC_TARGET_TRIPLE})
44-
elseif(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT LIBC_GPU_BUILD)
45-
set(LIBC_INSTALL_LIBRARY_DIR
46-
lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
47-
else()
48-
set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX})
49-
endif()
50-
5145
install(
5246
TARGETS ${added_archive_targets}
5347
ARCHIVE DESTINATION ${LIBC_INSTALL_LIBRARY_DIR}

libc/startup/linux/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ foreach(target IN LISTS startup_components)
131131
set(fq_target_name libc.startup.linux.${target})
132132
add_dependencies(libc-startup ${fq_target_name})
133133
install(FILES $<TARGET_OBJECTS:${fq_target_name}>
134-
DESTINATION ${CMAKE_INSTALL_LIBDIR}
134+
DESTINATION ${LIBC_INSTALL_LIBRARY_DIR}
135135
RENAME $<TARGET_PROPERTY:${fq_target_name},OUTPUT_NAME>
136+
EXCLUDE_FROM_ALL
136137
COMPONENT libc)
137138
endforeach()

0 commit comments

Comments
 (0)