[libclc] [libclc] Remove bitcode prepare utility from OpenCL library build (PR #174447)
Joseph Huber via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 5 17:52:51 PST 2026
https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/174447
>From 454c4f9e4cb0ff20268b679635edeeba42ea9400 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 5 Jan 2026 11:16:41 -0600
Subject: [PATCH 1/2] [libclc] Remove bitcode prepare utility from OpenCL
library build
Summary:
This utility is unnecessary with the current usage. Right now it sets
linkage to linkonce_odr and deduplicates metadata nodes. The former is
not required as `-mlink-builtin-bitcode` will internalize all functions
anyway. The deduplication is no longer necessary as `llvm-link` handles
that. Removing this simplifies complexity and make it easier to
cross-build this utility as it no longer depends on host LLVM utilities
to be built in the proejct itself.
---
libclc/CMakeLists.txt | 3 ---
libclc/cmake/modules/AddLibclc.cmake | 20 +++++++-------------
2 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 985a568cc290b..b1fa8304f8fa2 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -198,9 +198,6 @@ list( SORT LIBCLC_TARGETS_TO_BUILD )
# headers are not $build/include/ which is what LLVM_INCLUDE_DIR is set to.
include_directories( ${LLVM_INCLUDE_DIRS} )
-# Configure prepare_builtins
-add_subdirectory( utils )
-
# Setup arch devices
set( r600--_devices cedar cypress barts cayman )
set( amdgcn--_devices tahiti )
diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake
index 53b8fa91bf3fe..24792dca1e2d3 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -437,27 +437,21 @@ function(add_libclc_builtin_set)
# Non-SPIR-V targets add an extra step to optimize the bytecode
set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} )
- add_custom_command( OUTPUT ${LIBCLC_ARCH_OBJFILE_DIR}/${builtins_opt_lib_tgt}.bc
- COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${LIBCLC_ARCH_OBJFILE_DIR}/${builtins_opt_lib_tgt}.bc
+ set( obj_suffix ${ARG_ARCH_SUFFIX}.bc )
+ set( libclc_builtins_lib ${LIBCLC_OUTPUT_LIBRARY_DIR}/${obj_suffix} )
+
+ add_custom_command( OUTPUT ${libclc_builtins_lib}
+ COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${libclc_builtins_lib}
${builtins_link_lib}
DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt}
)
add_custom_target( ${builtins_opt_lib_tgt}
- ALL DEPENDS ${LIBCLC_ARCH_OBJFILE_DIR}/${builtins_opt_lib_tgt}.bc
+ ALL DEPENDS ${libclc_builtins_lib}
)
set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES
- TARGET_FILE ${LIBCLC_ARCH_OBJFILE_DIR}/${builtins_opt_lib_tgt}.bc
+ TARGET_FILE ${libclc_builtins_lib}
FOLDER "libclc/Device IR/Opt"
)
-
- set( builtins_opt_lib $<TARGET_PROPERTY:${builtins_opt_lib_tgt},TARGET_FILE> )
-
- set( obj_suffix ${ARG_ARCH_SUFFIX}.bc )
- set( libclc_builtins_lib ${LIBCLC_OUTPUT_LIBRARY_DIR}/${obj_suffix} )
- add_custom_command( OUTPUT ${libclc_builtins_lib}
- COMMAND ${prepare_builtins_exe} -o ${libclc_builtins_lib} ${builtins_opt_lib}
- DEPENDS ${builtins_opt_lib} ${builtins_opt_lib_tgt} ${prepare_builtins_target}
- )
endif()
# Add a 'prepare' target
>From a1bfafb633930c00745ab7de9878a6faa65bf721 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 5 Jan 2026 19:51:59 -0600
Subject: [PATCH 2/2] prepare to library no redundant target
---
libclc/cmake/modules/AddLibclc.cmake | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake
index 24792dca1e2d3..b59391e69c9bb 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -445,32 +445,25 @@ function(add_libclc_builtin_set)
${builtins_link_lib}
DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt}
)
- add_custom_target( ${builtins_opt_lib_tgt}
- ALL DEPENDS ${libclc_builtins_lib}
- )
- set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES
- TARGET_FILE ${libclc_builtins_lib}
- FOLDER "libclc/Device IR/Opt"
- )
endif()
- # Add a 'prepare' target
- add_custom_target( prepare-${obj_suffix} ALL DEPENDS ${libclc_builtins_lib} )
- set_target_properties( "prepare-${obj_suffix}" PROPERTIES
+ # Add a 'library' target
+ add_custom_target( library-${obj_suffix} ALL DEPENDS ${libclc_builtins_lib} )
+ set_target_properties( "library-${obj_suffix}" PROPERTIES
TARGET_FILE ${libclc_builtins_lib}
- FOLDER "libclc/Device IR/Prepare"
+ FOLDER "libclc/Device IR/Library"
)
- # Also add a 'prepare' target for the triple. Since a triple may have
+ # Also add a 'library' target for the triple. Since a triple may have
# multiple devices, ensure we only try to create the triple target once. The
# triple's target will build all of the bytecode for its constituent devices.
- if( NOT TARGET prepare-${ARG_TRIPLE} )
- add_custom_target( prepare-${ARG_TRIPLE} ALL )
+ if( NOT TARGET library-${ARG_TRIPLE} )
+ add_custom_target( library-${ARG_TRIPLE} ALL )
endif()
- add_dependencies( prepare-${ARG_TRIPLE} prepare-${obj_suffix} )
+ add_dependencies( library-${ARG_TRIPLE} library-${obj_suffix} )
# Add dependency to top-level pseudo target to ease making other
# targets dependent on libclc.
- add_dependencies( ${ARG_PARENT_TARGET} prepare-${ARG_TRIPLE} )
+ add_dependencies( ${ARG_PARENT_TARGET} library-${ARG_TRIPLE} )
libclc_install(FILES ${libclc_builtins_lib})
@@ -505,7 +498,7 @@ function(add_libclc_builtin_set)
add_custom_command(
OUTPUT ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix}
COMMAND ${CMAKE_COMMAND} -E ${LIBCLC_LINK_OR_COPY} ${LIBCLC_LINK_OR_COPY_SOURCE} ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix}
- DEPENDS prepare-${obj_suffix}
+ DEPENDS library-${obj_suffix}
)
add_custom_target( alias-${alias_suffix} ALL
DEPENDS ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix}
More information about the cfe-commits
mailing list