Skip to content

Commit 2d2872c

Browse files
committed
[ET][Windows] Fix ExecuTorch Windows host build portability defects
Pull Request resolved: #20948 Building ExecuTorch (Vulkan backend plus core runtime) for a Windows x86_64 host with the arvr clang toolchain surfaced three genuine portability defects that fail under its strict `-Werror` set and generated-header wiring. These are correct fixes independent of any warning-suppression workaround. In `runtime/core/portable_type/c10/c10/targets.bzl`, the arvr-mode `select` that supplies the generated `ATen/Config.h` routed every non-Android OS to `ovrsource_aten_Config.h`, an OVR-native-only `oxx_static_library` that produces no output on the Windows host. The result was `fatal error: 'ATen/Config.h' file not found` in every CPU kernel that includes ATen vec headers. This adds an `ovr_config//os:windows` branch pointing at the working `generated_aten_config_header`, mirroring the existing Android fallback. In `backends/vulkan/runtime/api/containers/Tensor.h`, `size()` and `dim()` returned `const int64_t` by value; the meaningless top-level `const` on a scalar return trips `-Werror,-Wignored-qualifiers`. This header is included throughout the Vulkan backend, so it blocked `vulkan_graph_runtime`. The `const` qualifier is dropped. In `extension/data_loader/mman.h` and `mman_windows.cpp`, `#define NOMINMAX` was unconditional while the toolchain already predefines it, tripping `-Werror,-Wmacro-redefined` when compiling `mmap_data_loader` (pulled in by `Module`). Both sites are now guarded with `#ifndef NOMINMAX`. ghstack-source-id: 402995448 @exported-using-ghexport Differential Revision: [D112012051](https://our.internmc.facebook.com/intern/diff/D112012051/)
1 parent e16c048 commit 2d2872c

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

backends/vulkan/runtime/api/containers/Tensor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,11 +549,11 @@ class vTensor final {
549549
return sizes_;
550550
}
551551

552-
inline const int64_t size(size_t dim) const {
552+
inline int64_t size(size_t dim) const {
553553
return sizes().at(dim);
554554
}
555555

556-
inline const int64_t dim() const {
556+
inline int64_t dim() const {
557557
return sizes_.size();
558558
}
559559

extension/data_loader/mman.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,13 @@ ET_INLINE void fcntl_rdadvise_apple(int fd, size_t file_size) {
8181

8282
#else
8383

84+
#ifndef NOMINMAX
8485
#define NOMINMAX
8586
#include <windows.h>
8687
#undef NOMINMAX
88+
#else
89+
#include <windows.h>
90+
#endif
8791
#include <io.h>
8892

8993
#include <executorch/extension/data_loader/mman_windows.h>

extension/data_loader/mman_windows.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@
2323
#include <io.h>
2424
#include <cstdint>
2525
#include <limits>
26+
#ifndef NOMINMAX
2627
#define NOMINMAX
2728
#include <windows.h>
2829
#undef NOMINMAX
30+
#else
31+
#include <windows.h>
32+
#endif
2933

3034
#ifndef STATUS_SECTION_TOO_BIG
3135
#define STATUS_SECTION_TOO_BIG 0xC0000040L

runtime/core/portable_type/c10/c10/targets.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ def define_common_targets():
8181
"ovr_config//build_mode:arvr_mode[enabled]": select({
8282
"DEFAULT": ["fbsource//xplat/caffe2:ovrsource_aten_Config.h"],
8383
# ovrsource_aten_Config.h is an oxx_static_library that only
84-
# works on OVR-native platforms. On Android, it produces no
85-
# outputs, so use the xplat variant instead.
84+
# works on OVR-native platforms. On Android and the Windows
85+
# host, it produces no outputs, so use the xplat variant.
8686
"ovr_config//os:android": ["fbsource//xplat/caffe2:generated_aten_config_header"],
87+
"ovr_config//os:windows": ["fbsource//xplat/caffe2:generated_aten_config_header"],
8788
}),
8889
}) + get_sleef_deps(),
8990
fbcode_exported_deps = ([

0 commit comments

Comments
 (0)