Skip to content

Commit e63e353

Browse files
authored
Stop validating that build_variables.bzl matches buck-generated executorch_srcs.cmake (#13392)
The previous PR switched to build_variables.bzl as the source of truth. We can land this PR when we are happy to stop requiring Buck.
1 parent ce9c22d commit e63e353

File tree

2 files changed

+66
-143
lines changed

2 files changed

+66
-143
lines changed

CMakeLists.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -318,17 +318,6 @@ if(EXECUTORCH_SRCS_FILE)
318318
)
319319
endif()
320320
executorch_load_build_variables()
321-
if(NOT EXECUTORCH_SRCS_FILE)
322-
# A file wasn't provided. Run a script to extract the source lists from the
323-
# buck2 build system and write them to a file we can include.
324-
#
325-
# NOTE: This will only happen once during cmake setup, so it will not re-run
326-
# if the buck2 targets change.
327-
message(STATUS "executorch: Generating source lists")
328-
set(EXECUTORCH_SRCS_FILE "${CMAKE_CURRENT_BINARY_DIR}/executorch_srcs.cmake")
329-
extract_sources(${EXECUTORCH_SRCS_FILE})
330-
executorch_validate_build_variables()
331-
endif()
332321

333322
# Detect if an iOS toolchain is set.
334323
if(CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$")

tools/cmake/Codegen.cmake

Lines changed: 66 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -378,139 +378,73 @@ function(executorch_append_filelist name outputvar)
378378
)
379379
endfunction()
380380

381-
set(EXECUTORCH_BUILD_VARIABLES_FILELISTS
382-
EXECUTORCH_SRCS
383-
EXECUTORCH_CORE_SRCS
384-
PORTABLE_KERNELS_SRCS
385-
KERNELS_UTIL_ALL_DEPS_SRCS
386-
OPTIMIZED_KERNELS_SRCS
387-
QUANTIZED_KERNELS_SRCS
388-
PROGRAM_SCHEMA_SRCS
389-
OPTIMIZED_CPUBLAS_SRCS
390-
OPTIMIZED_NATIVE_CPU_OPS_SRCS
391-
TEST_BACKEND_COMPILER_LIB_SRCS
392-
EXTENSION_DATA_LOADER_SRCS
393-
EXTENSION_EVALUE_UTIL_SRCS
394-
EXTENSION_FLAT_TENSOR_SRCS
395-
EXTENSION_MODULE_SRCS
396-
EXTENSION_RUNNER_UTIL_SRCS
397-
EXTENSION_LLM_RUNNER_SRCS
398-
EXTENSION_TENSOR_SRCS
399-
EXTENSION_THREADPOOL_SRCS
400-
EXTENSION_TRAINING_SRCS
401-
TRAIN_XOR_SRCS
402-
EXECUTOR_RUNNER_SRCS
403-
SIZE_TEST_SRCS
404-
MPS_EXECUTOR_RUNNER_SRCS
405-
MPS_BACKEND_SRCS
406-
MPS_SCHEMA_SRCS
407-
XNN_EXECUTOR_RUNNER_SRCS
408-
XNNPACK_BACKEND_SRCS
409-
XNNPACK_SCHEMA_SRCS
410-
VULKAN_SCHEMA_SRCS
411-
CUSTOM_OPS_SRCS
412-
LLAMA_RUNNER_SRCS
413-
)
414-
set(EXECUTORCH_BUILD_VARIABLES_VARNAMES
415-
_executorch__srcs
416-
_executorch_core__srcs
417-
_portable_kernels__srcs
418-
_kernels_util_all_deps__srcs
419-
_optimized_kernels__srcs
420-
_quantized_kernels__srcs
421-
_program_schema__srcs
422-
_optimized_cpublas__srcs
423-
_optimized_native_cpu_ops__srcs
424-
_test_backend_compiler_lib__srcs
425-
_extension_data_loader__srcs
426-
_extension_evalue_util__srcs
427-
_extension_flat_tensor__srcs
428-
_extension_module__srcs
429-
_extension_runner_util__srcs
430-
_extension_llm_runner__srcs
431-
_extension_tensor__srcs
432-
_extension_threadpool__srcs
433-
_extension_training__srcs
434-
_train_xor__srcs
435-
_executor_runner__srcs
436-
_size_test__srcs
437-
_mps_executor_runner__srcs
438-
_mps_backend__srcs
439-
_mps_schema__srcs
440-
_xnn_executor_runner__srcs
441-
_xnnpack_backend__srcs
442-
_xnnpack_schema__srcs
443-
_vulkan_schema__srcs
444-
_custom_ops__srcs
445-
_llama_runner__srcs
446-
)
447-
448-
# Fail the build if the src lists in build_variables.bzl do not match the src
449-
# lists extracted from Buck and placed into EXECUTORCH_SRCS_FILE. This is
450-
# intended to be a safety mechanism while we are in the process of removing Buck
451-
# from the CMake build and replacing it with build_variables.bzl; if you are
452-
# seeing failures after you have intentionally changed Buck srcs, then simply
453-
# update build_variables.bzl. If you are seeing failures after changing
454-
# something about the build system, make sure your changes will work both before
455-
# and after we finish replacing Buck with build_variables.bzl, which should
456-
# involve getting these lists to match!
457-
function(executorch_validate_build_variables)
458-
include(${EXECUTORCH_SRCS_FILE})
459-
foreach(filelist_and_varname IN
460-
ZIP_LISTS EXECUTORCH_BUILD_VARIABLES_FILELISTS
461-
EXECUTORCH_BUILD_VARIABLES_VARNAMES
462-
)
463-
executorch_append_filelist(
464-
${filelist_and_varname_0}
465-
"${filelist_and_varname_1}_from_build_variables"
466-
)
467-
# The Buck and CMake mechanisms for getting the default PAL set up are
468-
# different. Prevent the Buck choice from flowing into CMake and causing
469-
# validation to fail, just like we do in our CMakeLists.txt.
470-
if("${filelist_and_varname_1}" STREQUAL "_executorch_core__srcs")
471-
list(FILTER ${filelist_and_varname_1} EXCLUDE REGEX
472-
"runtime/platform/default/[^/]*.cpp$"
473-
)
474-
endif()
475-
if(NOT ${filelist_and_varname_1} STREQUAL
476-
${filelist_and_varname_1}_from_build_variables
477-
)
478-
set(generated_items_not_in_build_variables ${${filelist_and_varname_1}})
479-
list(REMOVE_ITEM generated_items_not_in_build_variables
480-
${${filelist_and_varname_1}_from_build_variables}
481-
)
482-
483-
set(build_variables_items_not_in_generated
484-
${${filelist_and_varname_1}_from_build_variables}
485-
)
486-
list(REMOVE_ITEM build_variables_items_not_in_generated
487-
${${filelist_and_varname_1}}
488-
)
489-
490-
list(JOIN generated_items_not_in_build_variables "\n"
491-
pretty_generated_items_not_in_build_variables
492-
)
493-
list(JOIN build_variables_items_not_in_generated "\n"
494-
pretty_build_variables_items_not_in_generated
495-
)
496-
if(NOT pretty_generated_items_not_in_build_variables)
497-
set(pretty_generated_items_not_in_build_variables "<none>")
498-
endif()
499-
if(NOT pretty_build_variables_items_not_in_generated)
500-
set(pretty_build_variables_items_not_in_generated "<none>")
501-
endif()
502-
message(
503-
FATAL_ERROR
504-
"Buck-generated ${filelist_and_varname_1} does not match hardcoded "
505-
"${filelist_and_varname_0} in build_variables.bzl. Buck-generated items not in build_variables.bzl: "
506-
"${pretty_generated_items_not_in_build_variables}\n "
507-
"build_variables.bzl items not in buck-generated list: ${pretty_build_variables_items_not_in_generated}"
508-
)
509-
endif()
510-
endforeach()
511-
endfunction()
512-
513381
function(executorch_load_build_variables)
382+
set(EXECUTORCH_BUILD_VARIABLES_FILELISTS
383+
EXECUTORCH_SRCS
384+
EXECUTORCH_CORE_SRCS
385+
PORTABLE_KERNELS_SRCS
386+
KERNELS_UTIL_ALL_DEPS_SRCS
387+
OPTIMIZED_KERNELS_SRCS
388+
QUANTIZED_KERNELS_SRCS
389+
PROGRAM_SCHEMA_SRCS
390+
OPTIMIZED_CPUBLAS_SRCS
391+
OPTIMIZED_NATIVE_CPU_OPS_SRCS
392+
TEST_BACKEND_COMPILER_LIB_SRCS
393+
EXTENSION_DATA_LOADER_SRCS
394+
EXTENSION_EVALUE_UTIL_SRCS
395+
EXTENSION_FLAT_TENSOR_SRCS
396+
EXTENSION_MODULE_SRCS
397+
EXTENSION_RUNNER_UTIL_SRCS
398+
EXTENSION_LLM_RUNNER_SRCS
399+
EXTENSION_TENSOR_SRCS
400+
EXTENSION_THREADPOOL_SRCS
401+
EXTENSION_TRAINING_SRCS
402+
TRAIN_XOR_SRCS
403+
EXECUTOR_RUNNER_SRCS
404+
SIZE_TEST_SRCS
405+
MPS_EXECUTOR_RUNNER_SRCS
406+
MPS_BACKEND_SRCS
407+
MPS_SCHEMA_SRCS
408+
XNN_EXECUTOR_RUNNER_SRCS
409+
XNNPACK_BACKEND_SRCS
410+
XNNPACK_SCHEMA_SRCS
411+
VULKAN_SCHEMA_SRCS
412+
CUSTOM_OPS_SRCS
413+
LLAMA_RUNNER_SRCS
414+
)
415+
set(EXECUTORCH_BUILD_VARIABLES_VARNAMES
416+
_executorch__srcs
417+
_executorch_core__srcs
418+
_portable_kernels__srcs
419+
_kernels_util_all_deps__srcs
420+
_optimized_kernels__srcs
421+
_quantized_kernels__srcs
422+
_program_schema__srcs
423+
_optimized_cpublas__srcs
424+
_optimized_native_cpu_ops__srcs
425+
_test_backend_compiler_lib__srcs
426+
_extension_data_loader__srcs
427+
_extension_evalue_util__srcs
428+
_extension_flat_tensor__srcs
429+
_extension_module__srcs
430+
_extension_runner_util__srcs
431+
_extension_llm_runner__srcs
432+
_extension_tensor__srcs
433+
_extension_threadpool__srcs
434+
_extension_training__srcs
435+
_train_xor__srcs
436+
_executor_runner__srcs
437+
_size_test__srcs
438+
_mps_executor_runner__srcs
439+
_mps_backend__srcs
440+
_mps_schema__srcs
441+
_xnn_executor_runner__srcs
442+
_xnnpack_backend__srcs
443+
_xnnpack_schema__srcs
444+
_vulkan_schema__srcs
445+
_custom_ops__srcs
446+
_llama_runner__srcs
447+
)
514448
foreach(filelist_and_varname IN
515449
ZIP_LISTS EXECUTORCH_BUILD_VARIABLES_FILELISTS
516450
EXECUTORCH_BUILD_VARIABLES_VARNAMES

0 commit comments

Comments
 (0)