Skip to content

Commit 611092d

Browse files
authored
Enforce required cmake flags as explicit requirements (#11457)
### Summary The build file currently turns on a bunch of implicitly dependent flags, perhaps unnecessarily. Let's make these dependencies explicit now. For example, previously if `EXECUTORCH_BUILD_EXTENSION_TRAINING` was turned on, it would then turn on its own set of dependencies. This is good from a developer experience point of view because users would need to just turn on one flag. However, from a build point of view, it makes it harder to maintain and understand what flags are conflicting with one another. Now, if you want to build the training extension, you will have to explicitly turn on the required flags. However, with our build presets — most developers should not have to do to this! I have created a follow up ticket to actually comb through the existing flags and trim the fat if necessary: #11458 ### Test plan CI cc @larryliu0820
1 parent 8f05c35 commit 611092d

File tree

12 files changed

+81
-36
lines changed

12 files changed

+81
-36
lines changed

.ci/scripts/build-qnn-sdk.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ set_up_aot() {
3232
-DQNN_SDK_ROOT=${QNN_SDK_ROOT} \
3333
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
3434
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
35+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
36+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
3537
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
3638
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
3739
-DPYTHON_EXECUTABLE=python3

.ci/scripts/test_llama_torchao_lowbit.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ cmake -DPYTHON_EXECUTABLE=python \
3030
-DCMAKE_BUILD_TYPE=Release \
3131
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
3232
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
33+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
3334
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
3435
-DEXECUTORCH_BUILD_XNNPACK=OFF \
3536
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \

.ci/scripts/test_llava.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ EXECUTORCH_COMMON_CMAKE_ARGS=" \
3737
-DEXECUTORCH_ENABLE_LOGGING=ON \
3838
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3939
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
40+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
4041
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
4142
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
4243
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \

.ci/scripts/test_phi_3_mini.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ cmake_install_executorch_libraries() {
2727
-DEXECUTORCH_ENABLE_LOGGING=1 \
2828
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
2929
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
30+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
3031
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3132
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
3233
-DEXECUTORCH_BUILD_XNNPACK=ON \

.github/workflows/trunk.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ jobs:
552552
-DEXECUTORCH_ENABLE_LOGGING=1 \
553553
-DCMAKE_BUILD_TYPE=Release \
554554
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
555+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
555556
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
556557
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
557558
-DEXECUTORCH_BUILD_XNNPACK=ON \

CMakeLists.txt

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -152,37 +152,11 @@ else()
152152
endif()
153153

154154
if(EXECUTORCH_BUILD_TESTS)
155-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
156155
include(CTest)
157156
endif()
158157

159158
add_subdirectory(third-party)
160159

161-
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
162-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
163-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
164-
set(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
165-
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
166-
endif()
167-
168-
if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
169-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
170-
endif()
171-
172-
if(EXECUTORCH_BUILD_EXTENSION_MODULE)
173-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
174-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
175-
endif()
176-
177-
if(EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT)
178-
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
179-
set(EXECUTORCH_BUILD_KERNELS_CUSTOM ON)
180-
endif()
181-
182-
if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
183-
set(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)
184-
endif()
185-
186160
if(NOT DEFINED FXDIV_SOURCE_DIR)
187161
set(ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG
188162
${CMAKE_POSITION_INDEPENDENT_CODE}
@@ -336,7 +310,7 @@ if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
336310
" -fprofile-instr-generate -fcoverage-mapping"
337311
)
338312
else()
339-
message(ERROR
313+
message(FATAL_ERROR
340314
"Code coverage for compiler ${CMAKE_CXX_COMPILER_ID} is unsupported"
341315
)
342316
endif()

backends/qualcomm/scripts/build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ if [ "$BUILD_AARCH64" = true ]; then
8181
-DEXECUTORCH_BUILD_QNN=ON \
8282
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
8383
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
84+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
85+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
8486
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
8587
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
8688
-DQNN_SDK_ROOT=$QNN_SDK_ROOT \
@@ -127,6 +129,8 @@ if [ "$BUILD_X86_64" = true ]; then
127129
-DEXECUTORCH_BUILD_QNN=ON \
128130
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
129131
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
132+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
133+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
130134
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
131135
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
132136
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \

examples/models/phi-3-mini/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
2121
set(CMAKE_BUILD_TYPE Release)
2222

2323
# Set options for executorch build.
24-
option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER "" ON)
2524
option(EXECUTORCH_BUILD_EXTENSION_MODULE "" ON)
25+
option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER "" ON)
26+
option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR "" ON)
2627
option(EXECUTORCH_BUILD_EXTENSION_TENSOR "" ON)
2728
option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED "" ON)
2829
option(EXECUTORCH_BUILD_XNNPACK "" ON)

scripts/build_android_library.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ build_android_native_library() {
4747
-DEXECUTORCH_BUILD_XNNPACK=ON \
4848
-DEXECUTORCH_XNNPACK_SHARED_WORKSPACE=ON \
4949
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
50+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
5051
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
5152
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
5253
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \

tools/cmake/preset/apple_common.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ set_overridable_option(EXECUTORCH_XNNPACK_SHARED_WORKSPACE ON)
2222
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_APPLE ON)
2323
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
2424
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
25+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
2526
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
2627
set_overridable_option(EXECUTORCH_BUILD_KERNELS_CUSTOM ON)
2728
set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)

tools/cmake/preset/default.cmake

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,72 @@ define_overridable_option(
276276
"Enable weights cache to cache and manage all packed weights"
277277
BOOL OFF
278278
)
279+
define_overridable_option(
280+
EXECUTORCH_USE_CPP_CODE_COVERAGE
281+
"Build with code coverage enabled"
282+
BOOL OFF
283+
)
279284

280-
# MARK: - Validations
285+
# ------------------------------------------------------------------------------
286+
# Validations
287+
#
281288
# At this point all the options should be configured with their final value.
289+
# ------------------------------------------------------------------------------
290+
291+
check_required_options_on(
292+
IF_ON
293+
EXECUTORCH_ENABLE_EVENT_TRACER
294+
REQUIRES
295+
EXECUTORCH_BUILD_DEVTOOLS
296+
)
297+
298+
check_required_options_on(
299+
IF_ON
300+
EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR
301+
REQUIRES
302+
EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
303+
)
304+
305+
check_required_options_on(
306+
IF_ON
307+
EXECUTORCH_BUILD_EXTENSION_MODULE
308+
REQUIRES
309+
EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
310+
EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR
311+
)
312+
313+
check_required_options_on(
314+
IF_ON
315+
EXECUTORCH_BUILD_KERNELS_CUSTOM
316+
REQUIRES
317+
EXECUTORCH_BUILD_KERNELS_OPTIMIZED
318+
)
319+
320+
check_required_options_on(
321+
IF_ON
322+
EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT
323+
REQUIRES
324+
EXECUTORCH_BUILD_EXTENSION_TENSOR
325+
EXECUTORCH_BUILD_KERNELS_CUSTOM
326+
)
327+
328+
check_required_options_on(
329+
IF_ON
330+
EXECUTORCH_BUILD_EXTENSION_TRAINING
331+
REQUIRES
332+
EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
333+
EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR
334+
EXECUTORCH_BUILD_EXTENSION_MODULE
335+
EXECUTORCH_BUILD_EXTENSION_TENSOR
336+
)
337+
338+
check_required_options_on(
339+
IF_ON
340+
EXECUTORCH_BUILD_TESTS
341+
REQUIRES
342+
EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR
343+
)
344+
282345

283346
if(NOT EXISTS ${EXECUTORCH_PAL_DEFAULT_FILE_PATH})
284347
message(FATAL_ERROR "PAL default implementation (EXECUTORCH_PAL_DEFAULT=${EXECUTORCH_PAL_DEFAULT}) file not found: ${EXECUTORCH_PAL_DEFAULT_FILE_PATH}. Choices: posix, minimal, android")
@@ -299,13 +362,6 @@ else()
299362
endif()
300363

301364

302-
if(EXECUTORCH_ENABLE_EVENT_TRACER)
303-
if(NOT EXECUTORCH_BUILD_DEVTOOLS)
304-
message(FATAL_ERROR "Use of 'EXECUTORCH_ENABLE_EVENT_TRACER' requires 'EXECUTORCH_BUILD_DEVTOOLS' to be enabled.")
305-
endif()
306-
endif()
307-
308-
309365
if(EXECUTORCH_BUILD_ARM_BAREMETAL)
310366
if(EXECUTORCH_BUILD_PTHREADPOOL)
311367
message(FATAL_ERROR "Cannot enable both EXECUTORCH_BUILD_PTHREADPOOL and EXECUTORCH_BUILD_ARM_BAREMETAL")

tools/cmake/preset/pybind.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ set_overridable_option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL ON)
1818
set_overridable_option(EXECUTORCH_BUILD_KERNELS_CUSTOM ON)
1919
set_overridable_option(EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT ON)
2020
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
21+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
22+
set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)
2123

2224

2325
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")

0 commit comments

Comments
 (0)