================
@@ -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}
----------------
wenju-he wrote:
but we can still create .a library with bag of bitcodes, something like
following steps:
1. llvm-ar extract bitcode from ${ARG_LIBRARIES}
2. for each bitcode, use clang to link in ${ARG_INTERNALIZE_LIBRARIES} and
optimize
3. pack bitcodes into .a library.
https://github.com/llvm/llvm-project/pull/197247
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits