diff --git a/backends/vulkan/targets.bzl b/backends/vulkan/targets.bzl index b1105a08c51..d2dee601399 100644 --- a/backends/vulkan/targets.bzl +++ b/backends/vulkan/targets.bzl @@ -10,7 +10,13 @@ def get_vulkan_compiler_flags(): "-Wno-global-constructors", "-Wno-missing-prototypes", ], - "ovr_config//os:windows": [], + # The Windows clang host build needs -Werror relaxed for the vendored + # VMA headers, but MSVC cl.exe rejects the gcc-style flag, so exclude + # pure MSVC. OSS buck2 has no compiler constraint, so guard to non-OSS. + "ovr_config//os:windows": select({ + "DEFAULT": ["-Wno-error"], + "ovr_config//compiler:msvc": [], + }) if not runtime.is_oss else ["-Wno-error"], }) def get_vulkan_preprocessor_flags(no_volk, is_fbcode): diff --git a/kernels/optimized/cpu/targets.bzl b/kernels/optimized/cpu/targets.bzl index 9d54a5038bc..8e0f0b86408 100644 --- a/kernels/optimized/cpu/targets.bzl +++ b/kernels/optimized/cpu/targets.bzl @@ -48,6 +48,18 @@ def define_common_targets(): srcs = ["binary_ops.cpp"], exported_headers = ["binary_ops.h"], visibility = ["PUBLIC"], + # ATen vec headers trip -Werror warnings on the Windows clang host; + # MSVC cl.exe rejects the gcc-style flag. + compiler_flags = select({ + "DEFAULT": [], + # OSS buck2 has no compiler constraint (ovr_config//compiler:msvc + # resolves to the nonexistent prelude//compiler:msvc), so it cannot + # appear as a select key there; guard the MSVC branch to non-OSS. + "ovr_config//os:windows": select({ + "DEFAULT": ["-Wno-error"], + "ovr_config//compiler:msvc": [], + }) if not runtime.is_oss else ["-Wno-error"], + }), exported_deps = [ "//executorch/runtime/core/exec_aten:lib", "//executorch/runtime/kernel:kernel_includes", diff --git a/kernels/optimized/lib_defs.bzl b/kernels/optimized/lib_defs.bzl index 928fc44635d..2ea329a8baa 100644 --- a/kernels/optimized/lib_defs.bzl +++ b/kernels/optimized/lib_defs.bzl @@ -214,6 +214,15 @@ def define_libs(is_fbcode=False): # TODO: replace with get_compiler_optimization_flags from op_registration_util.bzl when that # is re-enabled. "DEFAULT": ["-Os"], + }) + select({ + "DEFAULT": [], + # ATen vec headers trip -Werror warnings on the Windows clang + # host; MSVC cl.exe rejects the gcc-style flag. OSS buck2 has no + # compiler constraint, so guard the MSVC branch to non-OSS. + "ovr_config//os:windows": select({ + "DEFAULT": ["-Wno-error"], + "ovr_config//compiler:msvc": [], + }) if not runtime.is_oss else ["-Wno-error"], }), header_namespace = "executorch/kernels/optimized", visibility = ["PUBLIC"], 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 4da5db56310..7e32f5b7473 100644 --- a/shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl +++ b/shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl @@ -109,6 +109,17 @@ def define_op_library(name, compiler_flags, deps): "ovr_config//os:zephyr": [ "-Wno-pass-failed", ], + # The vendored ATen vec headers trip several -Werror warnings on + # the Windows (clang) host, so disable warnings-as-errors there. + "ovr_config//os:windows": select({ + "DEFAULT": [ + "-Wno-missing-prototypes", + "-Wno-pass-failed", + "-Wno-error", + ], + # MSVC cl.exe rejects the gcc-style flags above. + "ovr_config//compiler:msvc": [], + }), }) if not runtime.is_oss else [ "-Wno-missing-prototypes", "-Wno-pass-failed", 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 65016cd1ca1..f1a46616295 100644 --- a/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl +++ b/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl @@ -124,13 +124,22 @@ def define_op_library(name, deps, android_deps, aten_target, _allow_third_party_ # 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. + # The vendored ATen vec headers pulled in on the Windows host trip + # several -Werror warnings (e.g. -Wundef on __GNUC__), so disable + # warnings-as-errors for the Windows (clang) kernel compiles. compiler_flags = (select({ "DEFAULT": ["-Wno-missing-prototypes"], - "ovr_config//os:windows": [], + "ovr_config//os:windows": select({ + "DEFAULT": ["-Wno-error"], + "ovr_config//compiler:msvc": [], + }), "ovr_config//os:zephyr": [], }) if not runtime.is_oss else select({ "DEFAULT": ["-Wno-missing-prototypes"], - "ovr_config//os:windows": [], + # OSS buck2 has no compiler constraint (ovr_config//compiler:msvc + # resolves to the nonexistent prelude//compiler:msvc), so it + # cannot appear as a select key. Use the clang flag directly. + "ovr_config//os:windows": ["-Wno-error"], })) + ( # For shared library build, we don't want to expose symbols of # kernel implementation (ex torch::executor::native::tanh_out)