diff --git a/backends/vulkan/runtime/api/containers/Tensor.h b/backends/vulkan/runtime/api/containers/Tensor.h index 30c243aedd5..83c714bbc90 100644 --- a/backends/vulkan/runtime/api/containers/Tensor.h +++ b/backends/vulkan/runtime/api/containers/Tensor.h @@ -549,11 +549,11 @@ class vTensor final { return sizes_; } - inline const int64_t size(size_t dim) const { + inline int64_t size(size_t dim) const { return sizes().at(dim); } - inline const int64_t dim() const { + inline int64_t dim() const { return sizes_.size(); } 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/extension/data_loader/mman.h b/extension/data_loader/mman.h index 9d3ee4be5aa..1d8df959692 100644 --- a/extension/data_loader/mman.h +++ b/extension/data_loader/mman.h @@ -81,9 +81,13 @@ ET_INLINE void fcntl_rdadvise_apple(int fd, size_t file_size) { #else +#ifndef NOMINMAX #define NOMINMAX #include #undef NOMINMAX +#else +#include +#endif #include #include diff --git a/extension/data_loader/mman_windows.cpp b/extension/data_loader/mman_windows.cpp index 9bc655a7827..67e211c4ca4 100644 --- a/extension/data_loader/mman_windows.cpp +++ b/extension/data_loader/mman_windows.cpp @@ -23,9 +23,13 @@ #include #include #include +#ifndef NOMINMAX #define NOMINMAX #include #undef NOMINMAX +#else +#include +#endif #ifndef STATUS_SECTION_TOO_BIG #define STATUS_SECTION_TOO_BIG 0xC0000040L 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/runtime/core/portable_type/c10/c10/targets.bzl b/runtime/core/portable_type/c10/c10/targets.bzl index 4c49232ae5c..675c04f97a1 100644 --- a/runtime/core/portable_type/c10/c10/targets.bzl +++ b/runtime/core/portable_type/c10/c10/targets.bzl @@ -81,9 +81,10 @@ def define_common_targets(): "ovr_config//build_mode:arvr_mode[enabled]": select({ "DEFAULT": ["fbsource//xplat/caffe2:ovrsource_aten_Config.h"], # ovrsource_aten_Config.h is an oxx_static_library that only - # works on OVR-native platforms. On Android, it produces no - # outputs, so use the xplat variant instead. + # works on OVR-native platforms. On Android and the Windows + # host, it produces no outputs, so use the xplat variant. "ovr_config//os:android": ["fbsource//xplat/caffe2:generated_aten_config_header"], + "ovr_config//os:windows": ["fbsource//xplat/caffe2:generated_aten_config_header"], }), }) + get_sleef_deps(), fbcode_exported_deps = ([ 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)