Skip to content

Commit cb1e91c

Browse files
authored
[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
1 parent 345748e commit cb1e91c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,13 @@ function(link_bc)
107107
set( LINK_INPUT_ARG "@${RSP_FILE}" )
108108
endif()
109109

110+
if( ARG_INTERNALIZE )
111+
set( link_flags --internalize --only-needed )
112+
endif()
113+
110114
add_custom_command(
111115
OUTPUT ${ARG_TARGET}.bc
112-
COMMAND ${llvm-link_exe} $<$<BOOL:${ARG_INTERNALIZE}>:--internalize> -o ${ARG_TARGET}.bc ${LINK_INPUT_ARG}
116+
COMMAND ${llvm-link_exe} ${link_flags} -o ${ARG_TARGET}.bc ${LINK_INPUT_ARG}
113117
DEPENDS ${llvm-link_target} ${ARG_DEPENDENCIES} ${ARG_INPUTS} ${RSP_FILE}
114118
)
115119

0 commit comments

Comments
 (0)