File tree Expand file tree Collapse file tree 5 files changed +107
-2
lines changed Expand file tree Collapse file tree 5 files changed +107
-2
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,10 @@ endif()
50
50
# -Os: Optimize for size -ffunction-sections -fdata-sections: breaks function
51
51
# and data into sections so they can be properly gc'd -s: strip symbols
52
52
set (CMAKE_CXX_FLAGS_RELEASE
53
- "-Os -ffunction-sections -fdata-sections -s -fno-exceptions -fno-rtti" )
53
+ "-Os -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti" )
54
+ if (NOT APPLE )
55
+ set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s" )
56
+ endif ()
54
57
set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g" )
55
58
56
59
# Option to register custom operator `my_ops::mul3` or `my_ops::mul4` or no
@@ -71,6 +74,9 @@ option(REGISTER_QUANTIZED_OPS
71
74
option (BUILD_SELECTIVE_BUILD_TEST
72
75
"Whether to build binary for demo selective build" OFF )
73
76
77
+ option (BUILD_SIZE_TEST
78
+ "Whether to build size test" OFF )
79
+
74
80
if (BUILD_SELECTIVE_BUILD_TEST )
75
81
option (SELECT_ALL_OPS
76
82
"Whether to register all ops defined in portable kernel library." OFF )
@@ -208,5 +214,10 @@ endif()
208
214
if (BUILD_SELECTIVE_BUILD_TEST )
209
215
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /examples/selective_build )
210
216
endif ()
217
+
218
+ # Add size test subdirectory
219
+ if (BUILD_SIZE_TEST )
220
+ add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /test )
221
+ endif ()
211
222
# Print all summary
212
223
executorch_print_configuration_summary ()
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ function(gen_selected_ops ops_schema_yaml root_ops include_all_ops)
25
25
if (include_all_ops )
26
26
list (APPEND _gen_oplist_command --include_all_operators )
27
27
endif ()
28
+
28
29
message ("Command - ${_gen_oplist_command} " )
29
30
add_custom_command (
30
31
COMMENT "Generating selected_operators.yaml for custom ops"
@@ -113,7 +114,9 @@ function(gen_operators_lib lib_name kernel_lib deps)
113
114
${CMAKE_CURRENT_BINARY_DIR} /Functions.h
114
115
${CMAKE_CURRENT_BINARY_DIR} /NativeFunctions.h )
115
116
target_link_libraries (${lib_name} PRIVATE ${deps} )
116
- target_link_libraries (${lib_name} INTERFACE ${kernel_lib} )
117
+ if (kernel_lib )
118
+ target_link_libraries (${lib_name} INTERFACE ${kernel_lib} )
119
+ endif ()
117
120
118
121
target_link_options_shared_lib (${lib_name} )
119
122
endfunction ()
Original file line number Diff line number Diff line change @@ -63,6 +63,20 @@ deps = [
63
63
" portable_kernels" ,
64
64
]
65
65
66
+ [targets .size_test ]
67
+ buck_targets = [
68
+ " //test:size_test" ,
69
+ ]
70
+ filters = [
71
+ " .cpp$" ,
72
+ ]
73
+ excludes = [
74
+ " ^codegen" ,
75
+ ]
76
+ deps = [
77
+ " executorch" ,
78
+ ]
79
+
66
80
[targets .xnnpack_schema ]
67
81
buck_targets = [
68
82
" //backends/xnnpack:xnnpack_schema"
Original file line number Diff line number Diff line change
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+ #
4
+ # This source code is licensed under the BSD-style license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ #
8
+ # Simple CMake build system for size_test demo.
9
+ #
10
+ # ### Editing this file ###
11
+ #
12
+ # This file should be formatted with
13
+ # ~~~
14
+ # cmake-format --first-comment-is-literal=True CMakeLists.txt
15
+ # ~~~
16
+ # It should also be cmake-lint clean.
17
+ #
18
+
19
+ cmake_minimum_required (VERSION 3.19 )
20
+ set (EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR} /.. )
21
+
22
+ set (_updated__srcs )
23
+ foreach (_src ${_size_test__srcs} )
24
+ list (APPEND _updated__srcs "${EXECUTORCH_ROOT} /${_src} " )
25
+ endforeach ()
26
+
27
+ #
28
+ # size_test: minimal binary with no ops and no delegate backend
29
+ #
30
+ add_executable (size_test ${_updated__srcs} )
31
+ target_link_libraries (size_test executorch )
32
+ if (CMAKE_BUILD_TYPE EQUAL "RELEASE" )
33
+ target_link_options (size_test PRIVATE "LINKER:--gc-sections" )
34
+ endif ()
35
+
36
+ # Print all summary
37
+ executorch_print_configuration_summary ()
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ # All rights reserved.
4
+ #
5
+ # This source code is licensed under the BSD-style license found in the
6
+ # LICENSE file in the root directory of this source tree.
7
+
8
+ # Build size_test and show the size of it
9
+ set -e
10
+
11
+ # shellcheck source=/dev/null
12
+ source " $( dirname " ${BASH_SOURCE[0]} " ) /../.ci/scripts/utils.sh"
13
+
14
+ test_cmake_size_test () {
15
+ (rm -rf cmake-out \
16
+ && mkdir cmake-out \
17
+ && cd cmake-out \
18
+ && retry cmake -DBUCK2=" $BUCK " \
19
+ -DBUILD_SIZE_TEST=ON \
20
+ -DCMAKE_BUILD_TYPE=Release \
21
+ -DPYTHON_EXECUTABLE=" $PYTHON_EXECUTABLE " ..)
22
+
23
+ echo " Build selective build test"
24
+ cmake --build cmake-out -j9 --config Release
25
+
26
+ echo ' Size of the binary:'
27
+ ls -al cmake-out/test/size_test
28
+ }
29
+
30
+ if [[ -z $BUCK ]];
31
+ then
32
+ BUCK=buck2
33
+ fi
34
+
35
+ if [[ -z $PYTHON_EXECUTABLE ]];
36
+ then
37
+ PYTHON_EXECUTABLE=python3
38
+ fi
39
+
40
+ test_cmake_size_test
You can’t perform that action at this time.
0 commit comments