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)
706706
707707 add_executable (executor_runner ${_executor_runner__srcs} )
708708 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)
714710 endif ()
715711 target_link_libraries (executor_runner ${_executor_runner_libs} )
716712 target_compile_options (executor_runner PUBLIC ${_common_compile_options} )
Original file line number Diff line number Diff line change @@ -210,10 +210,9 @@ endif()
210210
211211add_executable (llama_main ${_srcs} )
212212if (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" )
217216 endif ()
218217endif ()
219218
Original file line number Diff line number Diff line change @@ -198,10 +198,9 @@ list(APPEND _common_include_directories ${stb_SOURCE_DIR}
198198
199199add_executable (llava_main ${_srcs} )
200200if (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" )
205204 endif ()
206205endif ()
207206
Original file line number Diff line number Diff line change @@ -123,22 +123,22 @@ gen_selected_ops(
123123)
124124
125125generate_bindings_for_kernels(
126- LIB_NAME
127- "select_build_lib"
126+ LIB_NAME
127+ "select_build_lib"
128128 FUNCTIONS_YAML
129- ${EXECUTORCH_ROOT} /kernels/portable/functions.yaml
129+ ${EXECUTORCH_ROOT} /kernels/portable/functions.yaml
130130 CUSTOM_OPS_YAML
131131 "${_custom_ops_yaml} "
132132 DTYPE_SELECTIVE_BUILD
133133 "${EXECUTORCH_DTYPE_SELECTIVE_BUILD} "
134134)
135135
136136gen_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
142142 executorch_core
143143 DTYPE_SELECTIVE_BUILD
144144 "${EXECUTORCH_DTYPE_SELECTIVE_BUILD} "
@@ -152,7 +152,7 @@ list(TRANSFORM _executor_runner__srcs PREPEND "${EXECUTORCH_ROOT}/")
152152#
153153add_executable (selective_build_test ${_executor_runner__srcs} )
154154if (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)
156156endif ()
157157target_link_libraries (
158158 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}/")
5353add_executable (size_test ${_size_test__srcs} )
5454target_link_libraries (size_test executorch)
5555if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
56- target_link_options (size_test PRIVATE "LINKER:--gc-sections" )
56+ target_link_options_gc_sections (size_test)
5757endif ()
5858
5959#
@@ -65,7 +65,7 @@ target_link_libraries(
6565 size_test_all_ops executorch portable_ops_lib portable_kernels
6666)
6767if (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)
6969endif ()
7070
7171#
@@ -77,6 +77,6 @@ target_link_options_shared_lib(optimized_native_cpu_ops_lib)
7777target_link_libraries (
7878 size_test_all_optimized_ops executorch optimized_native_cpu_ops_lib)
7979if (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)
8181endif ()
8282endif ()
Original file line number Diff line number Diff line change @@ -59,6 +59,14 @@ function(target_link_options_shared_lib target_name)
5959 endif ()
6060endfunction ()
6161
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+
6270# Extract source files based on toml config. This is useful to keep buck2 and
6371# cmake aligned. Do not regenerate if file exists.
6472function (extract_sources sources_file)
You can’t perform that action at this time.
0 commit comments