================
@@ -63,53 +63,76 @@ function(libclc_add_builtin_library target_name)
     ${ARGN}
   )
 
-  add_library(${target_name} STATIC)
+  add_library(${target_name} OBJECT)
   target_compile_options(${target_name} PRIVATE ${ARG_COMPILE_OPTIONS})
   target_include_directories(${target_name} PRIVATE ${ARG_INCLUDE_DIRS})
   target_compile_definitions(${target_name} PRIVATE ${ARG_COMPILE_DEFINITIONS})
-  set_target_properties(${target_name} PROPERTIES
-    ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-    FOLDER ${ARG_FOLDER}
-  )
+  set_target_properties(${target_name} PROPERTIES FOLDER ${ARG_FOLDER})
 endfunction()
 
-# Links one or more libclc builtin libraries together, optionally
-# internalizing dependencies, then produces a final .bc or .spv file.
-function(libclc_link_library target_name)
+# Links builtin libclc object libraries together into a merged bitcode or 
SPIR-V
+# file and a static archive.
+function(libclc_add_library target_name)
   cmake_parse_arguments(ARG
     ""
-    "ARCH;TRIPLE;TARGET_TRIPLE;FOLDER;OUTPUT_FILENAME"
+    "ARCH;TRIPLE;TARGET_TRIPLE;OUTPUT_FILENAME;PARENT_TARGET"
     "LIBRARIES;INTERNALIZE_LIBRARIES;OPT_FLAGS"
     ${ARGN}
   )
 
   if(NOT ARG_OUTPUT_FILENAME)
-    message(FATAL_ERROR "OUTPUT_FILENAME is required for libclc_link_library")
+    message(FATAL_ERROR "OUTPUT_FILENAME is required for libclc_add_library")
+  endif()
+  if(NOT ARG_PARENT_TARGET)
+    message(FATAL_ERROR "PARENT_TARGET is required for libclc_add_library")
   endif()
   if(NOT ARG_LIBRARIES)
-    message(FATAL_ERROR "LIBRARIES is required for libclc_link_library")
+    message(FATAL_ERROR "LIBRARIES is required for libclc_add_library")
   endif()
 
   set(library_dir ${LIBCLC_OUTPUT_LIBRARY_DIR}/${ARG_TARGET_TRIPLE})
   file(MAKE_DIRECTORY ${library_dir})
 
-  set(linked_bc ${CMAKE_CURRENT_BINARY_DIR}/${target_name}.linked.bc)
+  # Create a combined static archive from all object libraries for 
installation.
+  set(archive_target ${target_name}.a)
+  add_library(${archive_target} STATIC)
+  target_link_libraries(${archive_target} PRIVATE
+    ${ARG_LIBRARIES} ${ARG_INTERNALIZE_LIBRARIES}
----------------
jhuber6 wrote:

Like merging them into a single file? I prefer individual files because it lets 
the linker semantics do something similar to as-needed.

https://github.com/llvm/llvm-project/pull/197247
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to