Skip to content

[libc] Minor error on install step after building on LLVM 18 #93114

@lucasreis1

Description

@lucasreis1

I've been seeing a minor error when building libc using Ninja during the install step pertaining crti.o and crtn.o. Particularly, both files are never compiled and thus cmake returns me an error when installing libc:

CMake Error at projects/libc/startup/linux/cmake_install.cmake:55 (file):
  file INSTALL cannot find
  "/home/lucas.reis/llvm-18/build/projects/libc/startup/linux/CMakeFiles/libc.startup.linux.crti.dir/./crti.cpp.o":
  No such file or directory.
Call Stack (most recent call first):
  projects/libc/startup/cmake_install.cmake:47 (include)
  projects/libc/cmake_install.cmake:77 (include)
  projects/cmake_install.cmake:47 (include)
  cmake_install.cmake:122 (include)


FAILED: CMakeFiles/install.util 

If I manually compile the object by calling ninja, the install works accordingly after:

lucas.reis:~/llvm-18/build$ ninja libc.startup.linux.crti
[1/1] Building CXX object projects/libc/startup/linux/CMakeFiles/libc.startup.linux.crti.dir/crti.cpp.o
lucas.reis:~/llvm-18/build$ ninja libc.startup.linux.crtn
[1/1] Building CXX object projects/libc/startup/linux/CMakeFiles/libc.startup.linux.crtn.dir/crtn.cpp.o

It is my understanding that those files are built with EXCLUDE_FROM_ALL:

add_library(
${fq_target_name}
EXCLUDE_FROM_ALL
OBJECT
${ADD_OBJECT_SRCS}
${ADD_OBJECT_HDRS}
)

and thus not compiled excplicitly unless requested, but they are still required in the install step:

add_startup_object(
crti
SRC
crti.cpp
)
add_startup_object(
crtn
SRC
crtn.cpp
)
add_custom_target(libc-startup)
set(startup_components crt1 crti crtn)
foreach(target IN LISTS startup_components)
set(fq_target_name libc.startup.linux.${target})
add_dependencies(libc-startup ${fq_target_name})
install(FILES $<TARGET_OBJECTS:${fq_target_name}>
DESTINATION ${CMAKE_INSTALL_LIBDIR}
RENAME $<TARGET_PROPERTY:${fq_target_name},OUTPUT_NAME>
COMPONENT libc)
endforeach()

Being startup object files it makes sense to me that they should be dependencies for libc to build on linux.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions