Skip to content

Commit b473287

Browse files
committed
[ET][Windows] Relax -Werror for ExecuTorch CPU kernels on the Windows host
Pull Request resolved: #20899 The arvr Windows clang toolchain enables a stricter `-Werror` warning set than the sanctioned ET build platforms, and vendored third-party headers that ExecuTorch does not own trip it. VMA's `vk_mem_alloc.h` hits `-Werror,-Winconsistent-missing-destructor-override`, and PyTorch's `ATen/cpu/vec/vec_base.h` uses `#if __GNUC__ <= 12` without `defined(__GNUC__)`, hitting `-Werror,-Wundef`. Because the offending code is in vendored headers we cannot patch, this disables warnings-as-errors for the affected compiles, scoped to `ovr_config//os:windows` only, so the clang target compiles are relaxed while the MSVC host tools and all non-Windows platforms are untouched. `backends/vulkan/targets.bzl` adds `-Wno-error` to the Vulkan targets (VMA header). The CPU-kernel build is split across four independent macros/targets, each of which includes the ATen vec headers and so needs the same relaxation: `kernels/portable/op_registration_util.bzl`, `kernels/optimized/op_registration_util.bzl`, the `binary_ops` support library in `kernels/optimized/cpu/targets.bzl`, and the `libblas` support library in `kernels/optimized/lib_defs.bzl`. ghstack-source-id: 402581011 @exported-using-ghexport Differential Revision: [D111811479](https://our.internmc.facebook.com/intern/diff/D111811479/)
1 parent 35cfcf9 commit b473287

5 files changed

Lines changed: 25 additions & 3 deletions

File tree

backends/vulkan/targets.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ def get_vulkan_compiler_flags():
1010
"-Wno-global-constructors",
1111
"-Wno-missing-prototypes",
1212
],
13-
"ovr_config//os:windows": [],
13+
"ovr_config//os:windows": [
14+
"-Wno-error",
15+
],
1416
})
1517

1618
def get_vulkan_preprocessor_flags(no_volk, is_fbcode):

kernels/optimized/cpu/targets.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ def define_common_targets():
4848
srcs = ["binary_ops.cpp"],
4949
exported_headers = ["binary_ops.h"],
5050
visibility = ["PUBLIC"],
51+
# ATen vec headers trip -Werror warnings on the Windows (clang) host.
52+
compiler_flags = select({
53+
"DEFAULT": [],
54+
"ovr_config//os:windows": ["-Wno-error"],
55+
}),
5156
exported_deps = [
5257
"//executorch/runtime/core/exec_aten:lib",
5358
"//executorch/runtime/kernel:kernel_includes",

kernels/optimized/lib_defs.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ def define_libs(is_fbcode=False):
214214
# TODO: replace with get_compiler_optimization_flags from op_registration_util.bzl when that
215215
# is re-enabled.
216216
"DEFAULT": ["-Os"],
217+
}) + select({
218+
"DEFAULT": [],
219+
# ATen vec headers trip -Werror warnings on the Windows (clang)
220+
# host.
221+
"ovr_config//os:windows": ["-Wno-error"],
217222
}),
218223
header_namespace = "executorch/kernels/optimized",
219224
visibility = ["PUBLIC"],

shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ def define_op_library(name, compiler_flags, deps):
109109
"ovr_config//os:zephyr": [
110110
"-Wno-pass-failed",
111111
],
112+
# The vendored ATen vec headers trip several -Werror warnings on
113+
# the Windows (clang) host, so disable warnings-as-errors there.
114+
"ovr_config//os:windows": [
115+
"-Wno-missing-prototypes",
116+
"-Wno-pass-failed",
117+
"-Wno-error",
118+
],
112119
}) if not runtime.is_oss else [
113120
"-Wno-missing-prototypes",
114121
"-Wno-pass-failed",

shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,16 @@ def define_op_library(name, deps, android_deps, aten_target, _allow_third_party_
124124
# Zephyr and Windows builds. OSS bypasses the zephyr branch via
125125
# runtime.is_oss since ovr_config//os:zephyr is not in the OSS
126126
# buck2 prelude.
127+
# The vendored ATen vec headers pulled in on the Windows host trip
128+
# several -Werror warnings (e.g. -Wundef on __GNUC__), so disable
129+
# warnings-as-errors for the Windows (clang) kernel compiles.
127130
compiler_flags = (select({
128131
"DEFAULT": ["-Wno-missing-prototypes"],
129-
"ovr_config//os:windows": [],
132+
"ovr_config//os:windows": ["-Wno-error"],
130133
"ovr_config//os:zephyr": [],
131134
}) if not runtime.is_oss else select({
132135
"DEFAULT": ["-Wno-missing-prototypes"],
133-
"ovr_config//os:windows": [],
136+
"ovr_config//os:windows": ["-Wno-error"],
134137
})) + (
135138
# For shared library build, we don't want to expose symbols of
136139
# kernel implementation (ex torch::executor::native::tanh_out)

0 commit comments

Comments
 (0)