From 0dbd56001d09a3279471d53880f9ef3c36c2ec4b Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Mon, 24 Feb 2025 12:10:17 -0800 Subject: [PATCH] Update [ghstack-poisoned] --- .buckconfig | 9 +-- build/Utils.cmake | 4 +- shim/BUCK | 23 -------- shim/README.md | 16 ------ shim_et/BUCK | 57 +++++++++++++++++++ shim_et/README.md | 19 +++++++ shim_et/tools | 1 + .../xplat/executorch/backends/backends.bzl | 0 .../backends/qualcomm/qnn_version.bzl | 0 .../xnnpack/third-party/third_party_libs.bzl | 0 .../xplat/executorch/build/env_interface.bzl | 0 .../executorch/build/runtime_wrapper.bzl | 0 .../xplat/executorch/build/selects.bzl | 0 .../xplat/executorch/build/type_defs.bzl | 0 .../xplat/executorch/codegen/codegen.bzl | 0 .../extension/pybindings/pybindings.bzl | 0 .../executorch/kernels/optimized/lib_defs.bzl | 0 .../optimized/op_registration_util.bzl | 0 .../kernels/portable/op_registration_util.bzl | 0 .../xplat/executorch/kernels/test/util.bzl | 0 20 files changed, 84 insertions(+), 45 deletions(-) delete mode 100644 shim/README.md create mode 100644 shim_et/BUCK create mode 100644 shim_et/README.md create mode 120000 shim_et/tools rename {shim => shim_et}/xplat/executorch/backends/backends.bzl (100%) rename {shim => shim_et}/xplat/executorch/backends/qualcomm/qnn_version.bzl (100%) rename {shim => shim_et}/xplat/executorch/backends/xnnpack/third-party/third_party_libs.bzl (100%) rename {shim => shim_et}/xplat/executorch/build/env_interface.bzl (100%) rename {shim => shim_et}/xplat/executorch/build/runtime_wrapper.bzl (100%) rename {shim => shim_et}/xplat/executorch/build/selects.bzl (100%) rename {shim => shim_et}/xplat/executorch/build/type_defs.bzl (100%) rename {shim => shim_et}/xplat/executorch/codegen/codegen.bzl (100%) rename {shim => shim_et}/xplat/executorch/extension/pybindings/pybindings.bzl (100%) rename {shim => shim_et}/xplat/executorch/kernels/optimized/lib_defs.bzl (100%) rename {shim => shim_et}/xplat/executorch/kernels/optimized/op_registration_util.bzl (100%) rename {shim => shim_et}/xplat/executorch/kernels/portable/op_registration_util.bzl (100%) rename {shim => shim_et}/xplat/executorch/kernels/test/util.bzl (100%) diff --git a/.buckconfig b/.buckconfig index 7a4aecd9710..a7c48881bb3 100644 --- a/.buckconfig +++ b/.buckconfig @@ -8,14 +8,15 @@ root = . prelude = third-party/prelude shim = shim + shim_et = shim_et [repository_aliases] config = prelude ovr_config = prelude - toolchains = shim - fbcode = shim - fbcode_macros = shim - fbsource = shim + toolchains = shim_et + fbcode = shim_et + fbcode_macros = shim_et + fbsource = shim_et buck = shim [cxx] diff --git a/build/Utils.cmake b/build/Utils.cmake index 113f4829b86..646ef5ff285 100644 --- a/build/Utils.cmake +++ b/build/Utils.cmake @@ -206,9 +206,9 @@ function(extract_sources sources_file) if(ANDROID_ABI) if("${ANDROID_ABI}" STREQUAL "arm64-v8a") - set(target_platforms_arg "--target-platforms=shim//:android-arm64") + set(target_platforms_arg "--target-platforms=shim_et//:android-arm64") elseif("${ANDROID_ABI}" STREQUAL "x86_64") - set(target_platforms_arg "--target-platforms=shim//:android-x86_64") + set(target_platforms_arg "--target-platforms=shim_et//:android-x86_64") else() message( FATAL_ERROR diff --git a/shim/BUCK b/shim/BUCK index 77f3742e2dc..55fdd5bb03f 100644 --- a/shim/BUCK +++ b/shim/BUCK @@ -61,26 +61,3 @@ remote_test_execution_toolchain( name = "remote_test_execution", visibility = ["PUBLIC"], ) - -execution_platform( - name = "android-arm64", - cpu_configuration = "prelude//cpu:arm64", - os_configuration = "prelude//os:android", - # REVIEW: not sure if this is correct - use_windows_path_separators = host_info().os.is_windows, - visibility = ["PUBLIC"], -) - -execution_platform( - name = "android-x86_64", - cpu_configuration = "prelude//cpu:x86_64", - os_configuration = "prelude//os:android", - # REVIEW: not sure if this is correct - use_windows_path_separators = host_info().os.is_windows, - visibility = ["PUBLIC"], -) - -noop_test_toolchain( - name = "test", - visibility = ["PUBLIC"], -) diff --git a/shim/README.md b/shim/README.md deleted file mode 100644 index 85933e51b2c..00000000000 --- a/shim/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# buck2 shims - -The `shim/` subtree helps the Meta-internal buck2 build system also work in the -open-source repo. - -Shims are how open-source buck2 supports a [line -like](https://github.com/pytorch/executorch/blob/50aa517549d10324147534d91d04a923b76421d6/kernels/optimized/targets.bzl#L1): - -``` -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") -``` - -In the open-source repo, `fbsource//xplat` (a Meta-internal root) doesn't exist. -The `shim = shim` line in `../.buckconfig` tells buck2 to look in -[`shim/xplat/executorch/build/runtime_wrapper.bzl`](https://github.com/pytorch/executorch/blob/main/shim/xplat/executorch/build/runtime_wrapper.bzl) -instead. diff --git a/shim_et/BUCK b/shim_et/BUCK new file mode 100644 index 00000000000..a1a9bdaf65d --- /dev/null +++ b/shim_et/BUCK @@ -0,0 +1,57 @@ +load("@prelude//platforms:defs.bzl", "execution_platform") +load("@prelude//tests:test_toolchain.bzl", "noop_test_toolchain") +load("@prelude//toolchains:cxx.bzl", "system_cxx_toolchain") +load("@prelude//toolchains:genrule.bzl", "system_genrule_toolchain") +load("@prelude//toolchains:python.bzl", "system_python_bootstrap_toolchain", "system_python_toolchain") +load("@prelude//toolchains:remote_test_execution.bzl", "remote_test_execution_toolchain") + +# Although the non-Android toolchains below are present in shim/BUCK, it appears that we +# have to duplicate them here or builds won't work. +system_cxx_toolchain( + name = "cxx", + cxx_flags = ["-std=c++20"], + visibility = ["PUBLIC"], +) + +system_genrule_toolchain( + name = "genrule", + visibility = ["PUBLIC"], +) + +system_python_toolchain( + name = "python", + visibility = ["PUBLIC"], +) + +system_python_bootstrap_toolchain( + name = "python_bootstrap", + visibility = ["PUBLIC"], +) + +execution_platform( + name = "android-arm64", + cpu_configuration = "prelude//cpu:arm64", + os_configuration = "prelude//os:android", + # REVIEW: not sure if this is correct + use_windows_path_separators = host_info().os.is_windows, + visibility = ["PUBLIC"], +) + +execution_platform( + name = "android-x86_64", + cpu_configuration = "prelude//cpu:x86_64", + os_configuration = "prelude//os:android", + # REVIEW: not sure if this is correct + use_windows_path_separators = host_info().os.is_windows, + visibility = ["PUBLIC"], +) + +noop_test_toolchain( + name = "test", + visibility = ["PUBLIC"], +) + +remote_test_execution_toolchain( + name = "remote_test_execution", + visibility = ["PUBLIC"], +) diff --git a/shim_et/README.md b/shim_et/README.md new file mode 100644 index 00000000000..a9e55273b0b --- /dev/null +++ b/shim_et/README.md @@ -0,0 +1,19 @@ +# buck2 shims + +The `shim_et/` subtree helps the Meta-internal buck2 build system also work in the +open-source repo. + +Shims are how open-source buck2 supports a [line +like](https://github.com/pytorch/executorch/blob/50aa517549d10324147534d91d04a923b76421d6/kernels/optimized/targets.bzl#L1): + +``` +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") +``` + +In the open-source repo, `fbsource//xplat` (a Meta-internal root) doesn't exist. +The `fbsource = shim_et` line in `../.buckconfig` tells buck2 to look in +[`shim_et/xplat/executorch/build/runtime_wrapper.bzl`](https://github.com/pytorch/executorch/blob/main/shim_et/xplat/executorch/build/runtime_wrapper.bzl) +instead. + +NOTE: `tools` is a symlink to `../shim/tools` because `fbsource//` +must refer here, but `fbsource//tools` in particular lives in `shim/`. diff --git a/shim_et/tools b/shim_et/tools new file mode 120000 index 00000000000..0b2cfeed777 --- /dev/null +++ b/shim_et/tools @@ -0,0 +1 @@ +../shim/tools \ No newline at end of file diff --git a/shim/xplat/executorch/backends/backends.bzl b/shim_et/xplat/executorch/backends/backends.bzl similarity index 100% rename from shim/xplat/executorch/backends/backends.bzl rename to shim_et/xplat/executorch/backends/backends.bzl diff --git a/shim/xplat/executorch/backends/qualcomm/qnn_version.bzl b/shim_et/xplat/executorch/backends/qualcomm/qnn_version.bzl similarity index 100% rename from shim/xplat/executorch/backends/qualcomm/qnn_version.bzl rename to shim_et/xplat/executorch/backends/qualcomm/qnn_version.bzl diff --git a/shim/xplat/executorch/backends/xnnpack/third-party/third_party_libs.bzl b/shim_et/xplat/executorch/backends/xnnpack/third-party/third_party_libs.bzl similarity index 100% rename from shim/xplat/executorch/backends/xnnpack/third-party/third_party_libs.bzl rename to shim_et/xplat/executorch/backends/xnnpack/third-party/third_party_libs.bzl diff --git a/shim/xplat/executorch/build/env_interface.bzl b/shim_et/xplat/executorch/build/env_interface.bzl similarity index 100% rename from shim/xplat/executorch/build/env_interface.bzl rename to shim_et/xplat/executorch/build/env_interface.bzl diff --git a/shim/xplat/executorch/build/runtime_wrapper.bzl b/shim_et/xplat/executorch/build/runtime_wrapper.bzl similarity index 100% rename from shim/xplat/executorch/build/runtime_wrapper.bzl rename to shim_et/xplat/executorch/build/runtime_wrapper.bzl diff --git a/shim/xplat/executorch/build/selects.bzl b/shim_et/xplat/executorch/build/selects.bzl similarity index 100% rename from shim/xplat/executorch/build/selects.bzl rename to shim_et/xplat/executorch/build/selects.bzl diff --git a/shim/xplat/executorch/build/type_defs.bzl b/shim_et/xplat/executorch/build/type_defs.bzl similarity index 100% rename from shim/xplat/executorch/build/type_defs.bzl rename to shim_et/xplat/executorch/build/type_defs.bzl diff --git a/shim/xplat/executorch/codegen/codegen.bzl b/shim_et/xplat/executorch/codegen/codegen.bzl similarity index 100% rename from shim/xplat/executorch/codegen/codegen.bzl rename to shim_et/xplat/executorch/codegen/codegen.bzl diff --git a/shim/xplat/executorch/extension/pybindings/pybindings.bzl b/shim_et/xplat/executorch/extension/pybindings/pybindings.bzl similarity index 100% rename from shim/xplat/executorch/extension/pybindings/pybindings.bzl rename to shim_et/xplat/executorch/extension/pybindings/pybindings.bzl diff --git a/shim/xplat/executorch/kernels/optimized/lib_defs.bzl b/shim_et/xplat/executorch/kernels/optimized/lib_defs.bzl similarity index 100% rename from shim/xplat/executorch/kernels/optimized/lib_defs.bzl rename to shim_et/xplat/executorch/kernels/optimized/lib_defs.bzl diff --git a/shim/xplat/executorch/kernels/optimized/op_registration_util.bzl b/shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl similarity index 100% rename from shim/xplat/executorch/kernels/optimized/op_registration_util.bzl rename to shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl diff --git a/shim/xplat/executorch/kernels/portable/op_registration_util.bzl b/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl similarity index 100% rename from shim/xplat/executorch/kernels/portable/op_registration_util.bzl rename to shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl diff --git a/shim/xplat/executorch/kernels/test/util.bzl b/shim_et/xplat/executorch/kernels/test/util.bzl similarity index 100% rename from shim/xplat/executorch/kernels/test/util.bzl rename to shim_et/xplat/executorch/kernels/test/util.bzl