File tree Expand file tree Collapse file tree 6 files changed +27
-25
lines changed Expand file tree Collapse file tree 6 files changed +27
-25
lines changed Original file line number Diff line number Diff line change @@ -706,11 +706,7 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
706
706
707
707
add_executable (executor_runner ${_executor_runner__srcs} )
708
708
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
709
- if (APPLE )
710
- target_link_options (executor_runner PRIVATE "LINKER:-dead_strip" )
711
- else ()
712
- target_link_options (executor_runner PRIVATE "LINKER:--gc-sections" )
713
- endif ()
709
+ target_link_options_gc_sections (executor_runner )
714
710
endif ()
715
711
target_link_libraries (executor_runner ${_executor_runner_libs} )
716
712
target_compile_options (executor_runner PUBLIC ${_common_compile_options} )
Original file line number Diff line number Diff line change @@ -210,10 +210,9 @@ endif()
210
210
211
211
add_executable (llama_main ${_srcs} )
212
212
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
213
- if (APPLE )
214
- target_link_options (llama_main PRIVATE "LINKER:-dead_strip" )
215
- else ()
216
- target_link_options (llama_main PRIVATE "LINKER:--gc-sections,-s" )
213
+ target_link_options_gc_sections (llama_main )
214
+ if (NOT APPLE )
215
+ target_link_options (llama_main PRIVATE "LINKER:-s" )
217
216
endif ()
218
217
endif ()
219
218
Original file line number Diff line number Diff line change @@ -198,10 +198,9 @@ list(APPEND _common_include_directories ${stb_SOURCE_DIR}
198
198
199
199
add_executable (llava_main ${_srcs} )
200
200
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
201
- if (APPLE )
202
- target_link_options (llava_main PRIVATE "LINKER:-dead_strip,-s" )
203
- else ()
204
- target_link_options (llava_main PRIVATE "LINKER:--gc-sections,-s" )
201
+ target_link_options_gc_sections (llama_main )
202
+ if (NOT APPLE )
203
+ target_link_options (llama_main PRIVATE "LINKER:-s" )
205
204
endif ()
206
205
endif ()
207
206
Original file line number Diff line number Diff line change @@ -123,22 +123,22 @@ gen_selected_ops(
123
123
)
124
124
125
125
generate_bindings_for_kernels (
126
- LIB_NAME
127
- "select_build_lib"
126
+ LIB_NAME
127
+ "select_build_lib"
128
128
FUNCTIONS_YAML
129
- ${EXECUTORCH_ROOT} /kernels/portable/functions.yaml
129
+ ${EXECUTORCH_ROOT} /kernels/portable/functions.yaml
130
130
CUSTOM_OPS_YAML
131
131
"${_custom_ops_yaml} "
132
132
DTYPE_SELECTIVE_BUILD
133
133
"${EXECUTORCH_DTYPE_SELECTIVE_BUILD} "
134
134
)
135
135
136
136
gen_operators_lib (
137
- LIB_NAME
138
- "select_build_lib"
139
- KERNEL_LIBS
140
- ${_kernel_lib}
141
- DEPS
137
+ LIB_NAME
138
+ "select_build_lib"
139
+ KERNEL_LIBS
140
+ ${_kernel_lib}
141
+ DEPS
142
142
executorch_core
143
143
DTYPE_SELECTIVE_BUILD
144
144
"${EXECUTORCH_DTYPE_SELECTIVE_BUILD} "
@@ -152,7 +152,7 @@ list(TRANSFORM _executor_runner__srcs PREPEND "${EXECUTORCH_ROOT}/")
152
152
#
153
153
add_executable (selective_build_test ${_executor_runner__srcs} )
154
154
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
155
- target_link_options (selective_build_test PRIVATE "LINKER:--gc-sections" )
155
+ target_link_options_gc_sections (selective_build_test )
156
156
endif ()
157
157
target_link_libraries (
158
158
selective_build_test PRIVATE executorch_core gflags select_build_lib
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ list(TRANSFORM _size_test__srcs PREPEND "${EXECUTORCH_ROOT}/")
53
53
add_executable (size_test ${_size_test__srcs} )
54
54
target_link_libraries (size_test executorch )
55
55
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
56
- target_link_options (size_test PRIVATE "LINKER:--gc-sections" )
56
+ target_link_options_gc_sections (size_test )
57
57
endif ()
58
58
59
59
#
@@ -65,7 +65,7 @@ target_link_libraries(
65
65
size_test_all_ops executorch portable_ops_lib portable_kernels
66
66
)
67
67
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
68
- target_link_options (size_test_all_ops PRIVATE "LINKER:--gc-sections" )
68
+ target_link_options_gc_sections (size_test_all_ops )
69
69
endif ()
70
70
71
71
#
@@ -77,6 +77,6 @@ target_link_options_shared_lib(optimized_native_cpu_ops_lib)
77
77
target_link_libraries (
78
78
size_test_all_optimized_ops executorch optimized_native_cpu_ops_lib )
79
79
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
80
- target_link_options (size_test_all_optimized_ops PRIVATE "LINKER:--gc-sections" )
80
+ target_link_options_gc_sections (size_test_all_optimized_ops )
81
81
endif ()
82
82
endif ()
Original file line number Diff line number Diff line change @@ -59,6 +59,14 @@ function(target_link_options_shared_lib target_name)
59
59
endif ()
60
60
endfunction ()
61
61
62
+ function (target_link_options_gc_sections target_name )
63
+ if (APPLE )
64
+ target_link_options (${target_name} PRIVATE "LINKER:-dead_strip" )
65
+ else ()
66
+ target_link_options (${target_name} PRIVATE "LINKER:--gc-sections" )
67
+ endif ()
68
+ endfunction ()
69
+
62
70
# Extract source files based on toml config. This is useful to keep buck2 and
63
71
# cmake aligned. Do not regenerate if file exists.
64
72
function (extract_sources sources_file )
You can’t perform that action at this time.
0 commit comments