Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / libc / startup / gpu / CMakeLists.txt
blob9d0e0885dff9390c3f140aaa8d8022cd672bc129
1 function(add_startup_object name)
2   cmake_parse_arguments(
3     "ADD_STARTUP_OBJECT"
4     "ALIAS" # Option argument
5     "SRC"   # Single value arguments
6     "DEPENDS;COMPILE_OPTIONS" # Multi value arguments
7     ${ARGN}
8   )
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})
14     return()
15   endif()
17   add_object_library(
18     ${name}
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}
23   )
24   set_target_properties(
25     ${fq_target_name}
26     PROPERTIES
27       OUTPUT_NAME ${name}.o
28   )
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")
38   endif()
39 endfunction()
41 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_ARCHITECTURE})
42   add_subdirectory(${LIBC_TARGET_ARCHITECTURE})
43 endif()
45 add_startup_object(
46   crt1
47   ALIAS
48   DEPENDS
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>
60           COMPONENT libc)
61 endforeach()