1 function(add_startup_object name)
4 "ALIAS" # Option argument
5 "SRC" # Single value arguments
6 "DEPENDS;COMPILE_OPTIONS" # Multi value arguments
10 get_fq_target_name(${name} fq_target_name)
11 if(ADD_STARTUP_OBJECT_ALIAS)
12 get_fq_deps_list(fq_dep_list ${ADD_STARTUP_OBJECT_DEPENDS})
13 add_library(${fq_target_name} ALIAS ${fq_dep_list})
19 SRCS ${ADD_STARTUP_OBJECT_SRC}
20 COMPILE_OPTIONS ${ADD_STARTUP_OBJECT_COMPILE_OPTIONS}
21 ${ADD_STARTUP_OBJECT_UNPARSED_ARGUMENTS}
22 DEPENDS ${ADD_STARTUP_OBJECT_DEPENDS}
24 set_target_properties(
30 # Make an executable target of relocatable bitcode for clang if needed.
31 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
32 add_executable(${fq_target_name}.exe $<TARGET_OBJECTS:${fq_target_name}>)
33 set_target_properties(${fq_target_name}.exe PROPERTIES
34 RUNTIME_OUTPUT_DIRECTORY ${LIBC_LIBRARY_DIR}
35 RUNTIME_OUTPUT_NAME ${name}.o)
36 target_link_options(${fq_target_name}.exe PRIVATE
37 "-r" "-nostdlib" "-flto" "-Wl,--lto-emit-llvm")
41 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_ARCHITECTURE})
42 add_subdirectory(${LIBC_TARGET_ARCHITECTURE})
49 .${LIBC_TARGET_ARCHITECTURE}.crt1
52 add_custom_target(libc-startup)
53 set(startup_components crt1)
54 foreach(target IN LISTS startup_components)
55 set(fq_target_name libc.startup.gpu.${target})
56 add_dependencies(libc-startup ${fq_target_name})
57 install(FILES $<TARGET_OBJECTS:${fq_target_name}>
58 DESTINATION ${LIBC_INSTALL_LIBRARY_DIR}
59 RENAME $<TARGET_PROPERTY:${fq_target_name},OUTPUT_NAME>