From b3a7cd89c131517c7aa8836ddefb2a200ce0ea22 Mon Sep 17 00:00:00 2001 From: Niyas Sait Date: Wed, 2 Feb 2022 13:08:57 +0000 Subject: [PATCH] Enable native support for Windows on arm64 (Part 1) Contains following changes to third_party: - Extended def_parser to handle ARM64 binaries - Add grpc patch to workaround build issues Closes: https://github.com/bazelbuild/bazel/pull/14689 Partial commit for third_party/*, see #14689. Signed-off-by: Yun Peng --- third_party/def_parser/def_parser.cc | 1 + third_party/grpc/BUILD | 1 + third_party/grpc/grpc_1.41.0.win_arm64.patch | 51 ++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 third_party/grpc/grpc_1.41.0.win_arm64.patch diff --git a/third_party/def_parser/def_parser.cc b/third_party/def_parser/def_parser.cc index 2ed2db6cd1c5dd..08b383f462439d 100644 --- a/third_party/def_parser/def_parser.cc +++ b/third_party/def_parser/def_parser.cc @@ -378,6 +378,7 @@ bool DumpFile(const char* filename, std::set& symbols, /* Does it look like a COFF OBJ file??? */ else if (((dosHeader->e_magic == IMAGE_FILE_MACHINE_I386) || (dosHeader->e_magic == IMAGE_FILE_MACHINE_AMD64) || + (dosHeader->e_magic == IMAGE_FILE_MACHINE_ARM64) || (dosHeader->e_magic == IMAGE_FILE_MACHINE_ARMNT)) && (dosHeader->e_sp == 0)) { /* diff --git a/third_party/grpc/BUILD b/third_party/grpc/BUILD index 00d1533b858987..09d036555fcc64 100644 --- a/third_party/grpc/BUILD +++ b/third_party/grpc/BUILD @@ -21,6 +21,7 @@ licenses(["notice"]) # Apache v2 exports_files([ "grpc_1.31.1.patch", "grpc_1.41.0.patch", + "grpc_1.41.0.win_arm64.patch" ]) package(default_visibility = ["//visibility:public"]) diff --git a/third_party/grpc/grpc_1.41.0.win_arm64.patch b/third_party/grpc/grpc_1.41.0.win_arm64.patch new file mode 100644 index 00000000000000..355c9dd4bd57e8 --- /dev/null +++ b/third_party/grpc/grpc_1.41.0.win_arm64.patch @@ -0,0 +1,51 @@ +From 6ce08c3da545358074eb66dc4202e0474fa5be1b Mon Sep 17 00:00:00 2001 +From: Niyas Sait +Date: Fri, 26 Nov 2021 02:43:37 -0800 +Subject: [PATCH] add workarounds to compile for win/arm64 + +--- + src/core/lib/transport/transport.cc | 8 ++++---- + third_party/cares/cares.BUILD | 2 +- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/core/lib/transport/transport.cc b/src/core/lib/transport/transport.cc +index 36060a6bd9..db847d53d2 100644 +--- a/src/core/lib/transport/transport.cc ++++ b/src/core/lib/transport/transport.cc +@@ -99,16 +99,16 @@ void grpc_stream_ref_init(grpc_stream_refcount* refcount, int /*initial_refs*/, + refcount, &refcount->slice_refcount); + } + +-static void move64(uint64_t* from, uint64_t* to) { ++static void move64bits(uint64_t* from, uint64_t* to) { + *to += *from; + *from = 0; + } + + void grpc_transport_move_one_way_stats(grpc_transport_one_way_stats* from, + grpc_transport_one_way_stats* to) { +- move64(&from->framing_bytes, &to->framing_bytes); +- move64(&from->data_bytes, &to->data_bytes); +- move64(&from->header_bytes, &to->header_bytes); ++ move64bits(&from->framing_bytes, &to->framing_bytes); ++ move64bits(&from->data_bytes, &to->data_bytes); ++ move64bits(&from->header_bytes, &to->header_bytes); + } + + void grpc_transport_move_stats(grpc_transport_stream_stats* from, +diff --git a/third_party/cares/cares.BUILD b/third_party/cares/cares.BUILD +index 7939021a25..430791aa8d 100644 +--- a/third_party/cares/cares.BUILD ++++ b/third_party/cares/cares.BUILD +@@ -22,7 +22,7 @@ config_setting( + + config_setting( + name = "windows", +- values = {"cpu": "x64_windows"}, ++ constraint_values = ["@platforms//os:windows"], + ) + + # Android is not officially supported through C++. +-- +2.33.0.windows.2 +