[libclc] cb1e91c - [libclc] add --only-needed to llvm-link when INTERNALIZE flag is set (#130871)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 20 06:25:58 PDT 2025
Author: Wenju He
Date: 2025-03-20T13:25:55Z
New Revision: cb1e91c18dd20f6b2d1c38ce93befab87f77ce0f
URL: https://github.com/llvm/llvm-project/commit/cb1e91c18dd20f6b2d1c38ce93befab87f77ce0f
DIFF: https://github.com/llvm/llvm-project/commit/cb1e91c18dd20f6b2d1c38ce93befab87f77ce0f.diff
LOG: [libclc] add --only-needed to llvm-link when INTERNALIZE flag is set (#130871)
When -internalize flag is passed to llvm-link, we only need to link in
needed symbols. This PR reduces size of linked bitcode, e.g. by removing
following symbols:
_Z12__clc_sw_fmaDv16_fS_S_
_Z12__clc_sw_fmaDv2_fS_S_
_Z12__clc_sw_fmaDv3_fS_S_
_Z12__clc_sw_fmaDv4_fS_S_
_Z12__clc_sw_fmaDv8_fS_S_
_Z12__clc_sw_fmafff
Added:
Modified:
libclc/cmake/modules/AddLibclc.cmake
Removed:
################################################################################
diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake
index 911559ff4bfa9..2ec6d3256f8a2 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -107,9 +107,13 @@ function(link_bc)
set( LINK_INPUT_ARG "@${RSP_FILE}" )
endif()
+ if( ARG_INTERNALIZE )
+ set( link_flags --internalize --only-needed )
+ endif()
+
add_custom_command(
OUTPUT ${ARG_TARGET}.bc
- COMMAND ${llvm-link_exe} $<$<BOOL:${ARG_INTERNALIZE}>:--internalize> -o ${ARG_TARGET}.bc ${LINK_INPUT_ARG}
+ COMMAND ${llvm-link_exe} ${link_flags} -o ${ARG_TARGET}.bc ${LINK_INPUT_ARG}
DEPENDS ${llvm-link_target} ${ARG_DEPENDENCIES} ${ARG_INPUTS} ${RSP_FILE}
)
More information about the cfe-commits
mailing list