Skip to content

Commit 5b933fc

Browse files
committed
[libc] Fix startup utilities failing to install in full build mode
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 cc374d8 commit 5b933fc

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-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: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,11 @@ foreach(archive IN ZIP_LISTS
3535
)
3636
if(LLVM_LIBC_FULL_BUILD)
3737
target_link_libraries(${archive_1} PUBLIC libc-headers)
38+
add_dependencies(${archive_1} libc-startup)
3839
endif()
3940
list(APPEND added_archive_targets ${archive_1})
4041
endforeach()
4142

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-
5143
install(
5244
TARGETS ${added_archive_targets}
5345
ARCHIVE DESTINATION ${LIBC_INSTALL_LIBRARY_DIR}

libc/startup/linux/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ 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>
136136
COMPONENT libc)
137137
endforeach()

0 commit comments

Comments
 (0)