diff --git a/kernels/aten/cpu/util/targets.bzl b/kernels/aten/cpu/util/targets.bzl index fa54cdfa2f6..983391d3613 100644 --- a/kernels/aten/cpu/util/targets.bzl +++ b/kernels/aten/cpu/util/targets.bzl @@ -17,6 +17,12 @@ def define_common_targets(): compiler_flags = select({ "DEFAULT": ["-Wno-missing-prototypes"], "ovr_config//os:windows": [], + # ovr_config//os:zephyr is fbsource-internal; OSS bypasses + # this branch via runtime.is_oss. + "ovr_config//os:zephyr": [], + }) if not runtime.is_oss else select({ + "DEFAULT": ["-Wno-missing-prototypes"], + "ovr_config//os:windows": [], }), deps = [ "//executorch/runtime/kernel:kernel_includes_aten", diff --git a/kernels/portable/cpu/pattern/targets.bzl b/kernels/portable/cpu/pattern/targets.bzl index 5df8fde3738..10159c7b540 100644 --- a/kernels/portable/cpu/pattern/targets.bzl +++ b/kernels/portable/cpu/pattern/targets.bzl @@ -54,7 +54,11 @@ def define_common_targets(): exported_headers = [ "pattern.h", ], - compiler_flags = ["-Wno-missing-prototypes"], + compiler_flags = select({ + "DEFAULT": ["-Wno-missing-prototypes"], + # ovr_config//os:zephyr is fbsource-internal; OSS bypasses this select via runtime.is_oss. + "ovr_config//os:zephyr": [], + }) if not runtime.is_oss else ["-Wno-missing-prototypes"], exported_deps = [ "//executorch/kernels/portable/cpu/util:broadcast_util", "//executorch/kernels/portable/cpu/util:functional_util", diff --git a/kernels/portable/cpu/util/targets.bzl b/kernels/portable/cpu/util/targets.bzl index 0f385c2c98b..17ccb2cb51a 100644 --- a/kernels/portable/cpu/util/targets.bzl +++ b/kernels/portable/cpu/util/targets.bzl @@ -47,7 +47,11 @@ def define_common_targets(): exported_headers = [ "activation_ops_util.h", ], - compiler_flags = ["-Wno-missing-prototypes"], + compiler_flags = select({ + "DEFAULT": ["-Wno-missing-prototypes"], + # ovr_config//os:zephyr is fbsource-internal; OSS bypasses this select via runtime.is_oss. + "ovr_config//os:zephyr": [], + }) if not runtime.is_oss else ["-Wno-missing-prototypes"], deps = [ "//executorch/runtime/core/exec_aten/util:tensor_shape_to_c_string", "//executorch/runtime/kernel:kernel_includes", @@ -97,7 +101,11 @@ def define_common_targets(): exported_headers = [ "dtype_util.h", ], - compiler_flags = ["-Wno-missing-prototypes"], + compiler_flags = select({ + "DEFAULT": ["-Wno-missing-prototypes"], + # ovr_config//os:zephyr is fbsource-internal; OSS bypasses this select via runtime.is_oss. + "ovr_config//os:zephyr": [], + }) if not runtime.is_oss else ["-Wno-missing-prototypes"], deps = [ "//executorch/runtime/kernel:kernel_includes", ], @@ -109,7 +117,11 @@ def define_common_targets(): exported_headers = [ "elementwise_util.h", ], - compiler_flags = ["-Wno-missing-prototypes"], + compiler_flags = select({ + "DEFAULT": ["-Wno-missing-prototypes"], + # ovr_config//os:zephyr is fbsource-internal; OSS bypasses this select via runtime.is_oss. + "ovr_config//os:zephyr": [], + }) if not runtime.is_oss else ["-Wno-missing-prototypes"], exported_deps = [ ":broadcast_indexes_range", ":broadcast_util", @@ -141,7 +153,11 @@ def define_common_targets(): exported_headers = [ "advanced_index_util.h", ], - compiler_flags = ["-Wno-missing-prototypes"], + compiler_flags = select({ + "DEFAULT": ["-Wno-missing-prototypes"], + # ovr_config//os:zephyr is fbsource-internal; OSS bypasses this select via runtime.is_oss. + "ovr_config//os:zephyr": [], + }) if not runtime.is_oss else ["-Wno-missing-prototypes"], deps = [ ":broadcast_util", "//executorch/runtime/core/exec_aten/util:tensor_shape_to_c_string", @@ -156,7 +172,11 @@ def define_common_targets(): exported_headers = [ "copy_ops_util.h", ], - compiler_flags = ["-Wno-missing-prototypes"], + compiler_flags = select({ + "DEFAULT": ["-Wno-missing-prototypes"], + # ovr_config//os:zephyr is fbsource-internal; OSS bypasses this select via runtime.is_oss. + "ovr_config//os:zephyr": [], + }) if not runtime.is_oss else ["-Wno-missing-prototypes"], exported_deps = [ ":broadcast_util", ], @@ -172,7 +192,11 @@ def define_common_targets(): exported_headers = [ "distance_util.h", ], - compiler_flags = ["-Wno-missing-prototypes"], + compiler_flags = select({ + "DEFAULT": ["-Wno-missing-prototypes"], + # ovr_config//os:zephyr is fbsource-internal; OSS bypasses this select via runtime.is_oss. + "ovr_config//os:zephyr": [], + }) if not runtime.is_oss else ["-Wno-missing-prototypes"], deps = [ "//executorch/runtime/kernel:kernel_includes", ], @@ -188,7 +212,11 @@ def define_common_targets(): exported_headers = [ "kernel_ops_util.h", ], - compiler_flags = ["-Wno-missing-prototypes"], + compiler_flags = select({ + "DEFAULT": ["-Wno-missing-prototypes"], + # ovr_config//os:zephyr is fbsource-internal; OSS bypasses this select via runtime.is_oss. + "ovr_config//os:zephyr": [], + }) if not runtime.is_oss else ["-Wno-missing-prototypes"], deps = [ "//executorch/runtime/kernel:kernel_includes", ], @@ -201,7 +229,11 @@ def define_common_targets(): exported_headers = [ "matmul_ops_util.h", ], - compiler_flags = ["-Wno-missing-prototypes"], + compiler_flags = select({ + "DEFAULT": ["-Wno-missing-prototypes"], + # ovr_config//os:zephyr is fbsource-internal; OSS bypasses this select via runtime.is_oss. + "ovr_config//os:zephyr": [], + }) if not runtime.is_oss else ["-Wno-missing-prototypes"], deps = [ ":broadcast_util", "//executorch/runtime/kernel:kernel_includes", @@ -218,7 +250,11 @@ def define_common_targets(): exported_headers = [ "padding_util.h", ], - compiler_flags = ["-Wno-missing-prototypes"], + compiler_flags = select({ + "DEFAULT": ["-Wno-missing-prototypes"], + # ovr_config//os:zephyr is fbsource-internal; OSS bypasses this select via runtime.is_oss. + "ovr_config//os:zephyr": [], + }) if not runtime.is_oss else ["-Wno-missing-prototypes"], deps = [ "//executorch/runtime/kernel:kernel_includes", ], @@ -231,7 +267,11 @@ def define_common_targets(): exported_headers = [ "normalization_ops_util.h", ], - compiler_flags = ["-Wno-missing-prototypes"], + compiler_flags = select({ + "DEFAULT": ["-Wno-missing-prototypes"], + # ovr_config//os:zephyr is fbsource-internal; OSS bypasses this select via runtime.is_oss. + "ovr_config//os:zephyr": [], + }) if not runtime.is_oss else ["-Wno-missing-prototypes"], deps = [ "//executorch/runtime/kernel:kernel_includes", ], diff --git a/shim_et/xplat/executorch/codegen/codegen.bzl b/shim_et/xplat/executorch/codegen/codegen.bzl index 8b17171ec4e..5ffa7b65a36 100644 --- a/shim_et/xplat/executorch/codegen/codegen.bzl +++ b/shim_et/xplat/executorch/codegen/codegen.bzl @@ -632,7 +632,14 @@ def build_portable_lib( # Currently fbcode links all dependent libraries through shared # library, and it blocks users like unit tests to use kernel # implementation directly. So we enable this for xplat only. - compiler_flags = ["-Wno-missing-prototypes"] + # -Wno-missing-prototypes is Clang-only for C++; GCC (used by Zephyr ARM + # cross-compilation) rejects it with -Werror, so exclude it for Zephyr. + # OSS bypasses the select since ovr_config//os:zephyr is not in the OSS + # buck2 prelude. + compiler_flags = select({ + "DEFAULT": ["-Wno-missing-prototypes"], + "ovr_config//os:zephyr": [], + }) if not runtime.is_oss else ["-Wno-missing-prototypes"] if not expose_operator_symbols and is_xplat(): # Removing '-fvisibility=hidden' exposes operator symbols. # This allows operators to be called outside of the kernel registry. @@ -678,7 +685,14 @@ def build_optimized_lib(name, oplist_header_name, portable_header_lib, feature = # Currently fbcode links all dependent libraries through shared # library, and it blocks users like unit tests to use kernel # implementation directly. So we enable this for xplat only. - compiler_flags = ["-Wno-missing-prototypes", "-Wno-pass-failed", "-Wno-global-constructors", "-Wno-shadow"] + # -Wno-missing-prototypes and -Wno-global-constructors are Clang-only for + # C++; GCC (used by Zephyr ARM cross-compilation) rejects them with + # -Werror, so exclude them for Zephyr. OSS bypasses the select since + # ovr_config//os:zephyr is not in the OSS buck2 prelude. + compiler_flags = select({ + "DEFAULT": ["-Wno-missing-prototypes", "-Wno-pass-failed", "-Wno-global-constructors", "-Wno-shadow"], + "ovr_config//os:zephyr": ["-Wno-pass-failed", "-Wno-shadow"], + }) if not runtime.is_oss else ["-Wno-missing-prototypes", "-Wno-pass-failed", "-Wno-global-constructors", "-Wno-shadow"] if not expose_operator_symbols and is_xplat(): # Removing '-fvisibility=hidden' exposes operator symbols. # This allows operators to be called outside of the kernel registry. diff --git a/shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl b/shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl index fe77affcf36..4da5db56310 100644 --- a/shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl +++ b/shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl @@ -93,14 +93,26 @@ def define_op_library(name, compiler_flags, deps): "{}.cpp".format(name), ], visibility = ["PUBLIC"], - compiler_flags = [ + compiler_flags = (select({ # kernels often have helpers with no prototypes just disabling the warning here as the headers # are codegend and linked in later + # -Wno-missing-prototypes is Clang-only for C++; GCC (used by + # Zephyr ARM cross-compilation) rejects it with -Werror, so + # exclude it for Zephyr. OSS bypasses the select since + # ovr_config//os:zephyr is not in the OSS buck2 prelude. + "DEFAULT": [ + "-Wno-missing-prototypes", + # pragma unroll fails with -Os, don't need to warn us and + # fail Werror builds; see https://godbolt.org/z/zvf85vTsr + "-Wno-pass-failed", + ], + "ovr_config//os:zephyr": [ + "-Wno-pass-failed", + ], + }) if not runtime.is_oss else [ "-Wno-missing-prototypes", - # pragma unroll fails with -Os, don't need to warn us and - # fail Werror builds; see https://godbolt.org/z/zvf85vTsr "-Wno-pass-failed", - ] + compiler_flags + get_compiler_optimization_flags(), + ]) + compiler_flags + get_compiler_optimization_flags(), # sleef needs to be added as a direct dependency of the operator target when building for Android, # or a linker error may occur. Not sure why this happens; it seems that fbandroid_platform_deps of # dependencies are not transitive diff --git a/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl b/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl index c0af84a2477..cc2a0f78c75 100644 --- a/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl +++ b/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl @@ -119,10 +119,19 @@ def define_op_library(name, deps, android_deps, aten_target, _allow_third_party_ visibility = ["PUBLIC"], # kernels often have helpers with no prototypes just disabling the warning here as the headers # are codegend and linked in later - compiler_flags = select({ + # -Wno-missing-prototypes is Clang-only for C++; GCC (used by Zephyr + # ARM cross-compilation) rejects it with -Werror, so exclude it for + # Zephyr and Windows builds. OSS bypasses the zephyr branch via + # runtime.is_oss since ovr_config//os:zephyr is not in the OSS + # buck2 prelude. + compiler_flags = (select({ "DEFAULT": ["-Wno-missing-prototypes"], "ovr_config//os:windows": [], - }) + ( + "ovr_config//os:zephyr": [], + }) if not runtime.is_oss else select({ + "DEFAULT": ["-Wno-missing-prototypes"], + "ovr_config//os:windows": [], + })) + ( # For shared library build, we don't want to expose symbols of # kernel implementation (ex torch::executor::native::tanh_out) # to library users. They should use kernels through registry only.