diff --git a/.bazelci/build_bazel_binaries.yml b/.bazelci/build_bazel_binaries.yml index 17d49f042740ab..b42defbf20a301 100644 --- a/.bazelci/build_bazel_binaries.yml +++ b/.bazelci/build_bazel_binaries.yml @@ -49,3 +49,13 @@ platforms: build_targets: - "//src:bazel.exe" - "//src:bazel_nojdk.exe" + windows_arm64: + build_flags: + - "--copt=-w" + - "--host_copt=-w" + - "-c" + - "opt" + - "--cpu=x64_arm64_windows" + build_targets: + - "//src:bazel.exe" + - "//src:bazel_nojdk.exe" diff --git a/WORKSPACE b/WORKSPACE index 464a7a6f5a4c2b..2dd4db57c2b15d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -265,6 +265,13 @@ http_file( urls = ["https://mirror.bazel.build/openjdk/azul-zulu11.37.17-ca-jdk11.0.6/zulu11.37.17-ca-jdk11.0.6-win_x64.zip"], ) +http_file( + name = "openjdk_win_arm64_vanilla", + downloaded_file_path = "zulu-win-arm64.zip", + sha256 = "811d7e7591bac4f081dfb00ba6bd15b6fc5969e1f89f0f327ef75147027c3877", + urls = ["https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.30.15-ca-jdk17.0.1-win_aarch64.zip"], +) + http_file( name = "openjdk_win_minimal", downloaded_file_path = "zulu-win-minimal.zip", @@ -558,6 +565,14 @@ http_archive( urls = ["https://mirror.bazel.build/openjdk/azul-zulu11.50.19-ca-jdk11.0.12/zulu11.50.19-ca-jdk11.0.12-win_x64.zip"], ) +dist_http_archive( + name = "remotejdk11_win_arm64_for_testing", + build_file = "@local_jdk//:BUILD.bazel", + patch_cmds = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE, + patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE_WIN, + +) + # This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE. http_archive( name = "remotejdk15_linux_for_testing", @@ -726,6 +741,14 @@ http_archive( ], ) +dist_http_archive( + name = "remotejdk17_win_arm64_for_testing", + build_file = "@local_jdk//:BUILD.bazel", + patch_cmds = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE, + patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE_WIN, + +) + # Used in src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE. dist_http_archive( name = "remote_java_tools_for_testing", @@ -833,6 +856,18 @@ exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) urls = ["https://mirror.bazel.build/openjdk/azul-zulu11.50.19-ca-jdk11.0.12/zulu11.50.19-ca-jdk11.0.12-win_x64.zip"], ) +# This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives. +http_archive( + name = "openjdk11_windows_arm64_archive", + build_file_content = """ +java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public']) +exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) +""", + sha256 = "b8a28e6e767d90acf793ea6f5bed0bb595ba0ba5ebdf8b99f395266161e53ec2", + strip_prefix = "jdk-11.0.13+8", + urls = ["https://mirror.bazel.build/aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-windows-aarch64.zip"], +) + # This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives. http_archive( name = "openjdk15_linux_archive", @@ -1013,6 +1048,15 @@ exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) ], ) +# This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives. +dist_http_archive( + name = "openjdk17_windows_arm64_archive", + build_file_content = """ +java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public']) +exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) +""", +) + load("@io_bazel_skydoc//:setup.bzl", "stardoc_repositories") stardoc_repositories() diff --git a/distdir_deps.bzl b/distdir_deps.bzl index b872a69b50bebb..11dd547b7d2464 100644 --- a/distdir_deps.bzl +++ b/distdir_deps.bzl @@ -130,6 +130,7 @@ DIST_DEPS = { "patch_args": ["-p1"], "patches": [ "//third_party/grpc:grpc_1.41.0.patch", + "//third_party/grpc:grpc_1.41.0.win_arm64.patch", ], "used_in": [ "additional_distfiles", @@ -340,6 +341,34 @@ DIST_DEPS = { "test_WORKSPACE_files", ], }, + "remotejdk17_win_arm64": { + "aliases": [ + "remotejdk17_win_arm64_for_testing", + "openjdk17_windows_arm64_archive", + "openjdk_win_arm64_vanilla", + ], + "archive": "zulu17.30.15-ca-jdk17.0.1-win_aarch64.zip", + "sha256": "811d7e7591bac4f081dfb00ba6bd15b6fc5969e1f89f0f327ef75147027c3877", + "strip_prefix": "zulu17.30.15-ca-jdk17.0.1-win_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.30.15-ca-jdk17.0.1-win_aarch64.zip", + "https://cdn.azul.com/zulu/bin/zulu17.30.15-ca-jdk17.0.1-win_aarch64.zip", + ], + "used_in": ["test_WORKSPACE_files"], + }, + "remotejdk11_win_arm64": { + "aliases": [ + "remotejdk11_win_arm64_for_testing", + "openjdk11_windows_arm64_archive", + ], + "archive": "microsoft-jdk-11.0.13.8.1-windows-aarch64.zip", + "sha256": "b8a28e6e767d90acf793ea6f5bed0bb595ba0ba5ebdf8b99f395266161e53ec2", + "strip_prefix": "jdk-11.0.13+8", + "urls": [ + "https://mirror.bazel.build/aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-windows-aarch64.zip", + ], + "used_in": ["test_WORKSPACE_files"], + }, } # Add aliased names diff --git a/site/docs/windows.md b/site/docs/windows.md index df6009219b84bb..2356b4fb8055a0 100644 --- a/site/docs/windows.md +++ b/site/docs/windows.md @@ -203,7 +203,9 @@ target architecture, set the `--cpu` build option for your target architecture: * x64 (default): `--cpu=x64_windows` or no option * x86: `--cpu=x64_x86_windows` * ARM: `--cpu=x64_arm_windows` -* ARM64: `--cpu=x64_arm64_windows` +* ARM64: `--cpu=arm64_windows` + +Note: `--cpu=x64_arm64_windows` to target ARM64 architecture is deprecated. Please use `--cpu=arm64_windows` For example, to build targets for ARM architecture, run: diff --git a/src/BUILD b/src/BUILD index 8fdcf5b0637349..b08bffbf687474 100644 --- a/src/BUILD +++ b/src/BUILD @@ -148,7 +148,10 @@ filegroup( "//src/conditions:darwin_arm64": [ "@openjdk_macos_aarch64//file", ], - "//src/conditions:windows": [ + "//src/conditions:windows_arm64": [ + "@openjdk_win_arm64_vanilla//file", # TODO(#14339): replace with openjdk_win_arm64 when packages are uploaded to bazel mirror server + ], + "//src/conditions:windows_x86_64": [ "@openjdk_win//file", ], "//src/conditions:linux_aarch64": [ @@ -170,7 +173,10 @@ filegroup( "//src/conditions:darwin_arm64": [ "@openjdk_macos_aarch64_minimal//file", ], - "//src/conditions:windows": [ + "//src/conditions:windows_arm64": [ + "@openjdk_win_arm64_vanilla//file", # TODO(#14339): replace with openjdk_win_arm64 when packages are uploaded to bazel mirror server + ], + "//src/conditions:windows_x86_64": [ "@openjdk_win_minimal//file", ], "//src/conditions:linux_aarch64": [ @@ -649,6 +655,7 @@ filegroup( "@openjdk11_darwin_archive//:WORKSPACE", "@openjdk11_linux_archive//:WORKSPACE", "@openjdk11_windows_archive//:WORKSPACE", + "@openjdk11_windows_arm64_archive//:WORKSPACE", "@openjdk15_darwin_aarch64_archive//:WORKSPACE", "@openjdk15_darwin_archive//:WORKSPACE", "@openjdk15_linux_archive//:WORKSPACE", @@ -661,6 +668,7 @@ filegroup( "@openjdk17_darwin_archive//:WORKSPACE", "@openjdk17_linux_archive//:WORKSPACE", "@openjdk17_windows_archive//:WORKSPACE", + "@openjdk17_windows_arm64_archive//:WORKSPACE", "@openjdk_linux_aarch64_minimal//file", "@openjdk_linux_minimal//file", "@openjdk_macos_aarch64_minimal//file", @@ -681,6 +689,7 @@ filegroup( "@remotejdk11_linux_s390x_for_testing//:WORKSPACE", "@remotejdk11_macos_aarch64_for_testing//:WORKSPACE", "@remotejdk11_macos_for_testing//:WORKSPACE", + "@remotejdk11_win_arm64_for_testing//:WORKSPACE", "@remotejdk11_win_for_testing//:WORKSPACE", "@remotejdk15_linux_for_testing//:WORKSPACE", "@remotejdk15_macos_aarch64_for_testing//:WORKSPACE", @@ -693,6 +702,7 @@ filegroup( "@remotejdk17_linux_for_testing//:WORKSPACE", "@remotejdk17_macos_aarch64_for_testing//:WORKSPACE", "@remotejdk17_macos_for_testing//:WORKSPACE", + "@remotejdk17_win_arm64_for_testing//:WORKSPACE", "@remotejdk17_win_for_testing//:WORKSPACE", "@rules_cc//:WORKSPACE", "@rules_java//:WORKSPACE", diff --git a/src/conditions/BUILD b/src/conditions/BUILD index 073f8475ab45db..d5bfac64af3fc2 100644 --- a/src/conditions/BUILD +++ b/src/conditions/BUILD @@ -167,6 +167,45 @@ config_setting( visibility = ["//visibility:public"], ) +config_setting( + name = "windows_x86_64", + constraint_values = [ + "@platforms//os:windows", + "@platforms//cpu:x86_64", + ], + visibility = ["//visibility:public"], +) + +config_setting( + name = "windows_arm64_constraint", + constraint_values = [ + "@platforms//os:windows", + "@platforms//cpu:arm64", + ], +) + +# TODO(https://github.com/bazelbuild/bazel/issues/7260) +# Remove the flag after toolchain cc resolution is fixed +config_setting( + name = "windows_x64_arm64_flag", + values = {"cpu": "x64_arm64_windows"}, +) + +config_setting( + name = "windows_arm64_flag", + values = {"cpu": "arm64_windows"}, +) + +selects.config_setting_group( + name = "windows_arm64", + match_any = [ + ":windows_arm64_constraint", + ":windows_arm64_flag", + ":windows_x64_arm64_flag", + ], + visibility = ["//visibility:public"], +) + config_setting( name = "arm", constraint_values = ["@platforms//cpu:arm"], diff --git a/src/conditions/BUILD.tools b/src/conditions/BUILD.tools index e2b54e675d150a..aafdb4fb34786f 100644 --- a/src/conditions/BUILD.tools +++ b/src/conditions/BUILD.tools @@ -1,3 +1,5 @@ +load("//tools/windows:windows_config.bzl", "create_windows_host_config") + config_setting( name = "freebsd", constraint_values = ["@platforms//os:freebsd"], @@ -118,20 +120,30 @@ config_setting( visibility = ["//visibility:public"], ) -# TODO: figure out how to base this selection on constraints config_setting( - name = "windows_msvc", - values = {"cpu": "x64_windows_msvc"}, - visibility = ["//visibility:public"], + name = "windows_x64", + constraint_values = [ + "@platforms//os:windows", + "@platforms//cpu:x86_64", + ], +) +config_setting( + name = "windows_arm64", + constraint_values = [ + "@platforms//os:windows", + "@platforms//cpu:arm64", + ], ) # TODO: figure out how to base this selection on constraints config_setting( - name = "host_windows", - values = {"host_cpu": "x64_windows"}, + name = "windows_msvc", + values = {"cpu": "x64_windows_msvc"}, visibility = ["//visibility:public"], ) +create_windows_host_config() + config_setting( name = "remote", values = {"define": "EXECUTOR=remote"}, diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java b/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java index d39620c50eb1d7..07b1352088c3e8 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java @@ -50,8 +50,10 @@ public String convert(String input) throws OptionsParsingException { switch (CPU.getCurrent()) { case X86_64: return "x64_windows"; + case AARCH64: + return "arm64_windows"; default: - // We only support x64 Windows for now. + // We only support x64 and arm64 Windows for now. return "unknown"; } case LINUX: diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD index d82902b41dbc6b..ebbadd857a1820 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD @@ -84,6 +84,8 @@ gen_workspace_stanza( "remote_java_tools_linux", "remote_java_tools_windows", "remote_java_tools_darwin", + "remotejdk11_win_arm64", + "remotejdk17_win_arm64", "rules_cc", "rules_java", "rules_proto", diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl index 7040eaee4e881b..263c9214b46899 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl @@ -132,6 +132,22 @@ maybe( version = "11", ) +# This must be kept in sync with the top-level WORKSPACE file. +maybe( + remote_java_repository, + name = "remotejdk11_win_arm64", + exec_compatible_with = [ + "@platforms//os:windows", + "@platforms//cpu:arm64", + ], + sha256 = "b8a28e6e767d90acf793ea6f5bed0bb595ba0ba5ebdf8b99f395266161e53ec2", + strip_prefix = "jdk-11.0.13+8", + urls = [ + "https://mirror.bazel.build/aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-windows-aarch64.zip", + ], + version = "11", +) + # This must be kept in sync with the top-level WORKSPACE file. maybe( remote_java_repository, @@ -336,6 +352,22 @@ maybe( version = "17", ) +maybe( + remote_java_repository, + name = "remotejdk17_win_arm64", + exec_compatible_with = [ + "@platforms//os:windows", + "@platforms//cpu:arm64", + ], + sha256 = "811d7e7591bac4f081dfb00ba6bd15b6fc5969e1f89f0f327ef75147027c3877", + strip_prefix = "zulu17.30.15-ca-jdk17.0.1-win_aarch64", + urls = [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.30.15-ca-jdk17.0.1-win_aarch64.zip", + "https://cdn.azul.com/zulu/bin/zulu17.30.15-ca-jdk17.0.1-win_aarch64.zip", + ], + version = "17", +) + {remote_java_tools} {remote_java_tools_linux} {remote_java_tools_windows} diff --git a/src/test/py/bazel/bazel_windows_cpp_test.py b/src/test/py/bazel/bazel_windows_cpp_test.py index ce4c806ccce4cf..95f1280cfa9f7a 100644 --- a/src/test/py/bazel/bazel_windows_cpp_test.py +++ b/src/test/py/bazel/bazel_windows_cpp_test.py @@ -920,7 +920,7 @@ def testBuildArmCppBinaryWithMsvcCL(self): self.AssertExitCode(exit_code, 0, stderr) self.assertIn('arm\\cl.exe', '\n'.join(stderr)) - def testBuildArm64CppBinaryWithMsvcCL(self): + def testBuildArm64CppBinaryWithMsvcCLAndCpuX64Arm64Windows(self): self.CreateWorkspaceWithDefaultRepos('WORKSPACE') self.ScratchFile('BUILD', [ 'cc_binary(', @@ -1033,6 +1033,24 @@ def testBuildCppBinaryWithMsysGCC(self): self.AssertFileContentContains( os.path.join(bazel_output, paramfile % 'opt'), '-Wl,--gc-sections') + def testBuildArm64CppBinaryWithMsvcCLAndCpuArm64Windows(self): + self.CreateWorkspaceWithDefaultRepos('WORKSPACE') + self.ScratchFile('BUILD', [ + 'cc_binary(', + ' name = "main",', + ' srcs = ["main.cc"],', + ')', + ]) + self.ScratchFile('main.cc', [ + 'int main() {', + ' return 0;', + '}', + ]) + exit_code, _, stderr = self.RunBazel( + ['build', '-s', '--cpu=arm64_windows', '//:main']) + self.AssertExitCode(exit_code, 0, stderr) + self.assertIn('arm64\\cl.exe', ''.join(stderr)) + if __name__ == '__main__': unittest.main() diff --git a/src/test/py/bazel/test_base.py b/src/test/py/bazel/test_base.py index f980f8fd85b3ee..d722daee060779 100644 --- a/src/test/py/bazel/test_base.py +++ b/src/test/py/bazel/test_base.py @@ -64,6 +64,7 @@ class TestBase(unittest.TestCase): 'remotejdk11_macos_for_testing', 'remotejdk11_macos_aarch64_for_testing', 'remotejdk11_win_for_testing', + 'remotejdk11_win_arm64_for_testing', 'remotejdk15_linux_for_testing', 'remotejdk15_macos_for_testing', 'remotejdk15_macos_aarch64_for_testing', @@ -76,6 +77,7 @@ class TestBase(unittest.TestCase): 'remotejdk17_macos_for_testing', 'remotejdk17_macos_aarch64_for_testing', 'remotejdk17_win_for_testing', + 'remotejdk17_win_arm64_for_testing', 'remote_java_tools_for_testing', 'remote_java_tools_darwin_for_testing', 'remote_java_tools_linux_for_testing', diff --git a/src/test/shell/bazel/testdata/BUILD b/src/test/shell/bazel/testdata/BUILD index cecf6fe12dcf7e..aabb73f60e3f95 100644 --- a/src/test/shell/bazel/testdata/BUILD +++ b/src/test/shell/bazel/testdata/BUILD @@ -44,6 +44,8 @@ gen_workspace_stanza( "remote_java_tools_test_linux", "remote_java_tools_test_windows", "remote_java_tools_test_darwin", + "openjdk11_windows_arm64_archive", + "openjdk17_windows_arm64_archive", ], template = "jdk_http_archives.tmpl", visibility = ["//:__pkg__"], diff --git a/src/test/shell/bazel/testdata/jdk_http_archives.tmpl b/src/test/shell/bazel/testdata/jdk_http_archives.tmpl index 534e8e2d69b38a..358570e0a05278 100644 --- a/src/test/shell/bazel/testdata/jdk_http_archives.tmpl +++ b/src/test/shell/bazel/testdata/jdk_http_archives.tmpl @@ -166,6 +166,17 @@ exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) ], ) +# This must be kept in sync with the top-level WORKSPACE file. +http_archive( + name = "openjdk11_windows_arm64_archive", + build_file_content = "java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public'])", + sha256 = "b8a28e6e767d90acf793ea6f5bed0bb595ba0ba5ebdf8b99f395266161e53ec2", + strip_prefix = "jdk-11.0.13+8", + urls = [ + "https://mirror.bazel.build/aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-windows-aarch64.zip", + ], +) + #################################### JDK 17 #################################### # This must be kept in sync with the top-level WORKSPACE file. http_archive( @@ -226,3 +237,15 @@ exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-win_x64.zip", ], ) + +# This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives. +http_archive( + name = "openjdk17_windows_arm64_archive", + build_file_content = "java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public'])", + sha256 = "811d7e7591bac4f081dfb00ba6bd15b6fc5969e1f89f0f327ef75147027c3877", + strip_prefix = "zulu17.30.15-ca-jdk17.0.1-win_aarch64", + urls = [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.30.15-ca-jdk17.0.1-win_aarch64.zip", + "https://cdn.azul.com/zulu/bin/zulu17.30.15-ca-jdk17.0.1-win_aarch64.zip" + ], +) diff --git a/src/test/shell/bazel/verify_workspace.sh b/src/test/shell/bazel/verify_workspace.sh index ab1e3feeee3c3b..14f0e0390cdbf0 100755 --- a/src/test/shell/bazel/verify_workspace.sh +++ b/src/test/shell/bazel/verify_workspace.sh @@ -46,14 +46,18 @@ function test_verify_urls() { # Find url-shaped lines, skipping jekyll-tree (which isn't a valid URL), and # skipping comments. invalid_urls=() + checked_urls=() for file in "${WORKSPACE_FILES[@]}"; do for url in $(grep -E '"https://|http://' "${file}" | \ sed -e '/jekyll-tree/d' -e '/^#/d' -r -e 's#^.*"(https?://[^"]+)".*$#\1#g' | \ sort -u); do - #echo "Checking ${url}" - if ! curl --head -silent --fail --output /dev/null --retry 3 "${url}"; then - #fail "URL ${url} is invalid." - invalid_urls+=("${url}") + # add only unique url to the array + if [[ ${#checked_urls[@]} == 0 ]] || [[ ! " ${checked_urls[@]} " =~ " ${url} " ]]; then + checked_urls+=("${url}") + # echo "Checking ${url} ..." + if ! curl --head --silent --show-error --fail --output /dev/null --retry 3 "${url}"; then + invalid_urls+=("${url}") + fi fi done done diff --git a/src/test/shell/testenv.sh.tmpl b/src/test/shell/testenv.sh.tmpl index 184229d8528098..fbdb2a147cf36a 100755 --- a/src/test/shell/testenv.sh.tmpl +++ b/src/test/shell/testenv.sh.tmpl @@ -289,6 +289,7 @@ EOF "openjdk11_darwin_aarch64_archive" "openjdk11_linux_archive" "openjdk11_windows_archive" + "openjdk11_windows_arm64_archive" "openjdk15_darwin_archive" "openjdk15_darwin_aarch64_archive" "openjdk15_linux_archive" @@ -301,6 +302,7 @@ EOF "openjdk17_darwin_aarch64_archive" "openjdk17_linux_archive" "openjdk17_windows_archive" + "openjdk17_windows_arm64_archive" "openjdk_linux_aarch64_minimal" "openjdk_linux_minimal" "openjdk_macos_x86_64_minimal" @@ -334,6 +336,7 @@ EOF "remotejdk17_macos_for_testing" "remotejdk17_macos_aarch64_for_testing" "remotejdk17_win_for_testing" + "remotejdk17_win_arm64_for_testing" "rules_cc" "rules_java" "rules_proto" 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 + diff --git a/tools/BUILD b/tools/BUILD index 2f7b6743a8cd92..1d257df7f88232 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -24,6 +24,7 @@ filegroup( "//tools/objc:srcs", "//tools/osx:srcs", "//tools/osx/crosstool:srcs", + "//tools/windows:srcs", "//tools/test:srcs", "//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:srcs", "//tools/test/CoverageOutputGenerator/javatests/com/google/devtools/coverageoutputgenerator:srcs", @@ -55,6 +56,7 @@ filegroup( "//tools/jdk:srcs", "//tools/launcher:srcs", "//tools/def_parser:srcs", + "//tools/windows:srcs", "//tools/platforms:srcs", "//tools/objc:srcs", "//tools/python:embedded_tools", @@ -82,6 +84,7 @@ filegroup( "//tools/osx:bzl_srcs", "//tools/python:bzl_srcs", "//tools/sh:bzl_srcs", + "//tools/windows:bzl_srcs", ], ) diff --git a/tools/cpp/BUILD.windows.tpl b/tools/cpp/BUILD.windows.tpl index 9a249cef366ad8..4e4e50c4c4cc57 100644 --- a/tools/cpp/BUILD.windows.tpl +++ b/tools/cpp/BUILD.windows.tpl @@ -52,7 +52,8 @@ cc_toolchain_suite( "x64_windows|msvc-cl": ":cc-compiler-x64_windows", "x64_x86_windows|msvc-cl": ":cc-compiler-x64_x86_windows", "x64_arm_windows|msvc-cl": ":cc-compiler-x64_arm_windows", - "x64_arm64_windows|msvc-cl": ":cc-compiler-x64_arm64_windows", + "x64_arm64_windows|msvc-cl": ":cc-compiler-arm64_windows", + "arm64_windows|msvc-cl": ":cc-compiler-arm64_windows", "x64_windows|msys-gcc": ":cc-compiler-x64_windows_msys", "x64_windows|mingw-gcc": ":cc-compiler-x64_windows_mingw", "x64_windows|clang-cl": ":cc-compiler-x64_windows-clang-cl", @@ -60,7 +61,10 @@ cc_toolchain_suite( "x64_windows": ":cc-compiler-x64_windows", "x64_x86_windows": ":cc-compiler-x64_x86_windows", "x64_arm_windows": ":cc-compiler-x64_arm_windows", - "x64_arm64_windows": ":cc-compiler-x64_arm64_windows", + "x64_arm64_windows": ":cc-compiler-arm64_windows", + "arm64_windows": ":cc-compiler-arm64_windows", + "x64_arm64_windows|clang-cl": ":cc-compiler-arm64_windows-clang-cl", + "arm64_windows|clang-cl": ":cc-compiler-arm64_windows-clang-cl", "armeabi-v7a": ":cc-compiler-armeabi-v7a", }, ) @@ -356,9 +360,9 @@ toolchain( ) cc_toolchain( - name = "cc-compiler-x64_arm64_windows", - toolchain_identifier = "msvc_x64_arm64", - toolchain_config = ":msvc_x64_arm64", + name = "cc-compiler-arm64_windows", + toolchain_identifier = "msvc_arm64", + toolchain_config = ":msvc_arm64", all_files = ":empty", ar_files = ":empty", as_files = ":msvc_compiler_files", @@ -371,7 +375,7 @@ cc_toolchain( ) cc_toolchain_config( - name = "msvc_x64_arm64", + name = "msvc_arm64", cpu = "x64_windows", compiler = "msvc-cl", host_system_name = "local", @@ -379,7 +383,7 @@ cc_toolchain_config( target_libc = "msvcrt", abi_version = "local", abi_libc_version = "local", - toolchain_identifier = "msvc_x64_arm64", + toolchain_identifier = "msvc_arm64", msvc_env_tmp = "%{msvc_env_tmp_arm64}", msvc_env_path = "%{msvc_env_path_arm64}", msvc_env_include = "%{msvc_env_include_arm64}", @@ -408,16 +412,15 @@ cc_toolchain_config( ) toolchain( - name = "cc-toolchain-x64_arm64_windows", + name = "cc-toolchain-arm64_windows", exec_compatible_with = [ - "@platforms//cpu:x86_64", "@platforms//os:windows", ], target_compatible_with = [ "@platforms//cpu:arm64", "@platforms//os:windows", ], - toolchain = ":cc-compiler-x64_arm64_windows", + toolchain = ":cc-compiler-arm64_windows", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", ) @@ -447,22 +450,22 @@ cc_toolchain_config( abi_version = "local", abi_libc_version = "local", toolchain_identifier = "clang_cl_x64", - msvc_env_tmp = "%{clang_cl_env_tmp}", - msvc_env_path = "%{clang_cl_env_path}", - msvc_env_include = "%{clang_cl_env_include}", - msvc_env_lib = "%{clang_cl_env_lib}", - msvc_cl_path = "%{clang_cl_cl_path}", - msvc_ml_path = "%{clang_cl_ml_path}", - msvc_link_path = "%{clang_cl_link_path}", - msvc_lib_path = "%{clang_cl_lib_path}", - cxx_builtin_include_directories = [%{clang_cl_cxx_builtin_include_directories}], + msvc_env_tmp = "%{clang_cl_env_tmp_x64}", + msvc_env_path = "%{clang_cl_env_path_x64}", + msvc_env_include = "%{clang_cl_env_include_x64}", + msvc_env_lib = "%{clang_cl_env_lib_x64}", + msvc_cl_path = "%{clang_cl_cl_path_x64}", + msvc_ml_path = "%{clang_cl_ml_path_x64}", + msvc_link_path = "%{clang_cl_link_path_x64}", + msvc_lib_path = "%{clang_cl_lib_path_x64}", + cxx_builtin_include_directories = [%{clang_cl_cxx_builtin_include_directories_x64}], tool_paths = { - "ar": "%{clang_cl_lib_path}", - "ml": "%{clang_cl_ml_path}", - "cpp": "%{clang_cl_cl_path}", - "gcc": "%{clang_cl_cl_path}", + "ar": "%{clang_cl_lib_path_x64}", + "ml": "%{clang_cl_ml_path_x64}", + "cpp": "%{clang_cl_cl_path_x64}", + "gcc": "%{clang_cl_cl_path_x64}", "gcov": "wrapper/bin/msvc_nop.bat", - "ld": "%{clang_cl_link_path}", + "ld": "%{clang_cl_link_path_x64}", "nm": "wrapper/bin/msvc_nop.bat", "objcopy": "wrapper/bin/msvc_nop.bat", "objdump": "wrapper/bin/msvc_nop.bat", @@ -470,8 +473,8 @@ cc_toolchain_config( }, archiver_flags = ["/MACHINE:X64"], default_link_flags = ["/MACHINE:X64", "/DEFAULTLIB:clang_rt.builtins-x86_64.lib"], - dbg_mode_debug_flag = "%{clang_cl_dbg_mode_debug_flag}", - fastbuild_mode_debug_flag = "%{clang_cl_fastbuild_mode_debug_flag}", + dbg_mode_debug_flag = "%{clang_cl_dbg_mode_debug_flag_x64}", + fastbuild_mode_debug_flag = "%{clang_cl_fastbuild_mode_debug_flag_x64}", ) toolchain( @@ -489,6 +492,72 @@ toolchain( toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", ) +cc_toolchain( + name = "cc-compiler-arm64_windows-clang-cl", + toolchain_identifier = "clang_cl_arm64", + toolchain_config = ":clang_cl_arm64", + all_files = ":empty", + ar_files = ":empty", + as_files = ":clangcl_compiler_files", + compiler_files = ":clangcl_compiler_files", + dwp_files = ":empty", + linker_files = ":empty", + objcopy_files = ":empty", + strip_files = ":empty", + supports_param_files = 1, +) + +cc_toolchain_config( + name = "clang_cl_arm64", + cpu = "arm64_windows", + compiler = "clang-cl", + host_system_name = "local", + target_system_name = "aarch64-pc-windows-msvc", + target_libc = "msvcrt", + abi_version = "local", + abi_libc_version = "local", + toolchain_identifier = "clang_cl_arm64", + msvc_env_tmp = "%{clang_cl_env_tmp_arm64}", + msvc_env_path = "%{clang_cl_env_path_arm64}", + msvc_env_include = "%{clang_cl_env_include_arm64}", + msvc_env_lib = "%{clang_cl_env_lib_arm64}", + msvc_cl_path = "%{clang_cl_cl_path_arm64}", + msvc_ml_path = "%{clang_cl_ml_path_arm64}", + msvc_link_path = "%{clang_cl_link_path_arm64}", + msvc_lib_path = "%{clang_cl_lib_path_arm64}", + cxx_builtin_include_directories = [%{clang_cl_cxx_builtin_include_directories_arm64}], + tool_paths = { + "ar": "%{clang_cl_lib_path_arm64}", + "ml": "%{clang_cl_ml_path_arm64}", + "cpp": "%{clang_cl_cl_path_arm64}", + "gcc": "%{clang_cl_cl_path_arm64}", + "gcov": "wrapper/bin/msvc_nop.bat", + "ld": "%{clang_cl_link_path_arm64}", + "nm": "wrapper/bin/msvc_nop.bat", + "objcopy": "wrapper/bin/msvc_nop.bat", + "objdump": "wrapper/bin/msvc_nop.bat", + "strip": "wrapper/bin/msvc_nop.bat", + }, + archiver_flags = ["/MACHINE:ARM64"], + default_link_flags = ["/MACHINE:ARM64"], + dbg_mode_debug_flag = "%{clang_cl_dbg_mode_debug_flag_arm64}", + fastbuild_mode_debug_flag = "%{clang_cl_fastbuild_mode_debug_flag_arm64}", +) + +toolchain( + name = "cc-toolchain-arm64_windows-clang-cl", + exec_compatible_with = [ + "@platforms//os:windows", + "@bazel_tools//tools/cpp:clang-cl", + ], + target_compatible_with = [ + "@platforms//cpu:arm64", + "@platforms//os:windows", + ], + toolchain = ":cc-compiler-arm64_windows-clang-cl", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + cc_toolchain( name = "cc-compiler-armeabi-v7a", toolchain_identifier = "stub_armeabi-v7a", diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl index 8e5acc2ee319b6..473d43c8b26091 100644 --- a/tools/cpp/cc_configure.bzl +++ b/tools/cpp/cc_configure.bzl @@ -116,7 +116,7 @@ def cc_autoconf_impl(repository_ctx, overriden_tools = dict()): # container so skipping until we have proper tests for these platforms. repository_ctx.symlink(paths["@bazel_tools//tools/cpp:bsd_cc_toolchain_config.bzl"], "cc_toolchain_config.bzl") repository_ctx.symlink(paths["@bazel_tools//tools/cpp:BUILD.static.bsd"], "BUILD") - elif cpu_value == "x64_windows": + elif cpu_value in ["x64_windows", "arm64_windows"]: # TODO(ibiryukov): overriden_tools are only supported in configure_unix_toolchain. # We might want to add that to Windows too(at least for msys toolchain). configure_windows_toolchain(repository_ctx) diff --git a/tools/cpp/lib_cc_configure.bzl b/tools/cpp/lib_cc_configure.bzl index 9508eb78f7e9e5..cf602ab1b0cb76 100644 --- a/tools/cpp/lib_cc_configure.bzl +++ b/tools/cpp/lib_cc_configure.bzl @@ -189,7 +189,12 @@ def get_cpu_value(repository_ctx): if os_name.find("openbsd") != -1: return "openbsd" if os_name.find("windows") != -1: - return "x64_windows" + arch = (get_env_var(repository_ctx, "PROCESSOR_ARCHITECTURE", "", False) or + get_env_var(repository_ctx, "PROCESSOR_ARCHITEW6432", "", False)) + if arch == "ARM64": + return "arm64_windows" + else: + return "x64_windows" # Use uname to figure out whether we are on x86_32 or x86_64 result = repository_ctx.execute(["uname", "-m"]) diff --git a/tools/cpp/windows_cc_configure.bzl b/tools/cpp/windows_cc_configure.bzl index d0c16c48b93b43..c4fc61529e7403 100644 --- a/tools/cpp/windows_cc_configure.bzl +++ b/tools/cpp/windows_cc_configure.bzl @@ -323,6 +323,10 @@ def _get_vc_env_vars(repository_ctx, vc_path, msvc_vars_x64, target_arch): lib = msvc_vars_x64["%{msvc_env_lib_x64}"] full_version = _get_vc_full_version(repository_ctx, vc_path) tools_path = "%s\\Tools\\MSVC\\%s\\bin\\HostX64\\%s" % (vc_path, full_version, target_arch) + + # For native windows(10) on arm64 builds host toolchain runs in an emulated x86 environment + if not repository_ctx.path(tools_path).exists: + tools_path = "%s\\Tools\\MSVC\\%s\\bin\\HostX86\\%s" % (vc_path, full_version, target_arch) else: lib = msvc_vars_x64["%{msvc_env_lib_x64}"].replace("amd64", _targets_lib_folder[target_arch]) tools_path = vc_path + "\\bin\\" + _targets_archs[target_arch] @@ -448,6 +452,10 @@ def find_msvc_tool(repository_ctx, vc_path, tool, target_arch = "x64"): full_version = _get_vc_full_version(repository_ctx, vc_path) if full_version: tool_path = "%s\\Tools\\MSVC\\%s\\bin\\HostX64\\%s\\%s" % (vc_path, full_version, target_arch, tool) + + # For native windows(10) on arm64 builds host toolchain runs in an emulated x86 environment + if not repository_ctx.path(tool_path).exists: + tool_path = "%s\\Tools\\MSVC\\%s\\bin\\HostX86\\%s\\%s" % (vc_path, full_version, target_arch, tool) else: # For VS 2015 and older version, the tools are under: # C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64 @@ -685,12 +693,12 @@ def _get_msvc_vars(repository_ctx, paths, target_arch = "x64", msvc_vars_x64 = N } return msvc_vars -def _get_clang_cl_vars(repository_ctx, paths, msvc_vars): +def _get_clang_cl_vars(repository_ctx, paths, msvc_vars, target_arch): """Get the variables we need to populate the clang-cl toolchains.""" llvm_path = find_llvm_path(repository_ctx) error_script = None - if msvc_vars["%{msvc_cl_path_x64}"] == "vc_installation_error_x64.bat": - error_script = "vc_installation_error_x64.bat" + if msvc_vars["%{msvc_cl_path_" + target_arch + "}"] == "vc_installation_error_{}.bat".format(target_arch): + error_script = "vc_installation_error_{}.bat".format(target_arch) elif not llvm_path: repository_ctx.template( "clang_installation_error.bat", @@ -718,17 +726,17 @@ def _get_clang_cl_vars(repository_ctx, paths, msvc_vars): if error_script: write_builtin_include_directory_paths(repository_ctx, "clang-cl", [], file_suffix = "_clangcl") clang_cl_vars = { - "%{clang_cl_env_tmp}": "clang_cl_not_found", - "%{clang_cl_env_path}": "clang_cl_not_found", - "%{clang_cl_env_include}": "clang_cl_not_found", - "%{clang_cl_env_lib}": "clang_cl_not_found", - "%{clang_cl_cl_path}": error_script, - "%{clang_cl_link_path}": error_script, - "%{clang_cl_lib_path}": error_script, - "%{clang_cl_ml_path}": error_script, - "%{clang_cl_dbg_mode_debug_flag}": "/DEBUG", - "%{clang_cl_fastbuild_mode_debug_flag}": "/DEBUG", - "%{clang_cl_cxx_builtin_include_directories}": "", + "%{clang_cl_env_tmp_" + target_arch + "}": "clang_cl_not_found", + "%{clang_cl_env_path_" + target_arch + "}": "clang_cl_not_found", + "%{clang_cl_env_include_" + target_arch + "}": "clang_cl_not_found", + "%{clang_cl_env_lib_" + target_arch + "}": "clang_cl_not_found", + "%{clang_cl_cl_path_" + target_arch + "}": error_script, + "%{clang_cl_link_path_" + target_arch + "}": error_script, + "%{clang_cl_lib_path_" + target_arch + "}": error_script, + "%{clang_cl_ml_path_" + target_arch + "}": error_script, + "%{clang_cl_dbg_mode_debug_flag_" + target_arch + "}": "/DEBUG", + "%{clang_cl_fastbuild_mode_debug_flag_" + target_arch + "}": "/DEBUG", + "%{clang_cl_cxx_builtin_include_directories_" + target_arch + "}": "", } return clang_cl_vars @@ -741,21 +749,21 @@ def _get_clang_cl_vars(repository_ctx, paths, msvc_vars): clang_include_path = (clang_dir + "\\include").replace("\\", "\\\\") clang_lib_path = (clang_dir + "\\lib\\windows").replace("\\", "\\\\") - clang_cl_include_directories = msvc_vars["%{msvc_cxx_builtin_include_directories_x64}"] + (",\n \"%s\"" % clang_include_path) + clang_cl_include_directories = msvc_vars["%{msvc_cxx_builtin_include_directories_" + target_arch + "}"] + (",\n \"%s\"" % clang_include_path) write_builtin_include_directory_paths(repository_ctx, "clang-cl", [clang_cl_include_directories], file_suffix = "_clangcl") clang_cl_vars = { - "%{clang_cl_env_tmp}": msvc_vars["%{msvc_env_tmp_x64}"], - "%{clang_cl_env_path}": msvc_vars["%{msvc_env_path_x64}"], - "%{clang_cl_env_include}": msvc_vars["%{msvc_env_include_x64}"] + ";" + clang_include_path, - "%{clang_cl_env_lib}": msvc_vars["%{msvc_env_lib_x64}"] + ";" + clang_lib_path, - "%{clang_cl_cxx_builtin_include_directories}": clang_cl_include_directories, - "%{clang_cl_cl_path}": clang_cl_path, - "%{clang_cl_link_path}": lld_link_path, - "%{clang_cl_lib_path}": llvm_lib_path, - "%{clang_cl_ml_path}": msvc_vars["%{msvc_ml_path_x64}"], + "%{clang_cl_env_tmp_" + target_arch + "}": msvc_vars["%{msvc_env_tmp_" + target_arch + "}"], + "%{clang_cl_env_path_" + target_arch + "}": msvc_vars["%{msvc_env_path_" + target_arch + "}"], + "%{clang_cl_env_include_" + target_arch + "}": msvc_vars["%{msvc_env_include_" + target_arch + "}"] + ";" + clang_include_path, + "%{clang_cl_env_lib_" + target_arch + "}": msvc_vars["%{msvc_env_lib_" + target_arch + "}"] + ";" + clang_lib_path, + "%{clang_cl_cxx_builtin_include_directories_" + target_arch + "}": clang_cl_include_directories, + "%{clang_cl_cl_path_" + target_arch + "}": clang_cl_path, + "%{clang_cl_link_path_" + target_arch + "}": lld_link_path, + "%{clang_cl_lib_path_" + target_arch + "}": llvm_lib_path, + "%{clang_cl_ml_path_" + target_arch + "}": clang_cl_path, # LLVM's lld-link.exe doesn't support /DEBUG:FASTLINK. - "%{clang_cl_dbg_mode_debug_flag}": "/DEBUG", - "%{clang_cl_fastbuild_mode_debug_flag}": "/DEBUG", + "%{clang_cl_dbg_mode_debug_flag_" + target_arch + "}": "/DEBUG", + "%{clang_cl_fastbuild_mode_debug_flag_" + target_arch + "}": "/DEBUG", } return clang_cl_vars @@ -786,11 +794,13 @@ def configure_windows_toolchain(repository_ctx): template_vars = dict() msvc_vars_x64 = _get_msvc_vars(repository_ctx, paths, "x64") template_vars.update(msvc_vars_x64) - template_vars.update(_get_clang_cl_vars(repository_ctx, paths, msvc_vars_x64)) + template_vars.update(_get_clang_cl_vars(repository_ctx, paths, msvc_vars_x64, "x64")) template_vars.update(_get_msys_mingw_vars(repository_ctx)) template_vars.update(_get_msvc_vars(repository_ctx, paths, "x86", msvc_vars_x64)) template_vars.update(_get_msvc_vars(repository_ctx, paths, "arm", msvc_vars_x64)) - template_vars.update(_get_msvc_vars(repository_ctx, paths, "arm64", msvc_vars_x64)) + msvc_vars_arm64 = _get_msvc_vars(repository_ctx, paths, "arm64", msvc_vars_x64) + template_vars.update(msvc_vars_arm64) + template_vars.update(_get_clang_cl_vars(repository_ctx, paths, msvc_vars_arm64, "arm64")) repository_ctx.template( "BUILD", diff --git a/tools/cpp/windows_cc_toolchain_config.bzl b/tools/cpp/windows_cc_toolchain_config.bzl index f43f8ba3262ba3..f0233ceafbce76 100644 --- a/tools/cpp/windows_cc_toolchain_config.bzl +++ b/tools/cpp/windows_cc_toolchain_config.bzl @@ -80,7 +80,7 @@ all_link_actions = [ ] def _use_msvc_toolchain(ctx): - return ctx.attr.cpu == "x64_windows" and (ctx.attr.compiler == "msvc-cl" or ctx.attr.compiler == "clang-cl") + return ctx.attr.cpu in ["x64_windows", "arm64_windows"] and (ctx.attr.compiler == "msvc-cl" or ctx.attr.compiler == "clang-cl") def _impl(ctx): if _use_msvc_toolchain(ctx): diff --git a/tools/jdk/BUILD.tools b/tools/jdk/BUILD.tools index ecddfe0c3e1bed..347d15da336383 100644 --- a/tools/jdk/BUILD.tools +++ b/tools/jdk/BUILD.tools @@ -443,6 +443,7 @@ _JDKS = [ "remotejdk11_macos", "remotejdk11_macos_aarch64", "remotejdk11_win", + "remotejdk11_win_arm64", "remotejdk11_linux_aarch64", "remotejdk11_linux", "remotejdk11_linux_ppc64le", @@ -458,6 +459,7 @@ _JDKS = [ "remotejdk17_macos", "remotejdk17_macos_aarch64", "remotejdk17_win", + "remotejdk17_win_arm64", "remotejdk17_linux", ] diff --git a/tools/jdk/jdk.BUILD b/tools/jdk/jdk.BUILD index 687077146896ad..42acd3d723aa27 100644 --- a/tools/jdk/jdk.BUILD +++ b/tools/jdk/jdk.BUILD @@ -213,6 +213,6 @@ java_import( config_setting( name = "windows", - values = {"cpu": "x64_windows"}, + constraint_values = ["@platforms//os:windows"], visibility = ["//visibility:private"], ) diff --git a/tools/windows/BUILD b/tools/windows/BUILD new file mode 100644 index 00000000000000..c71554c023330c --- /dev/null +++ b/tools/windows/BUILD @@ -0,0 +1,11 @@ +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "srcs", + srcs = glob(["**"]), +) + +filegroup( + name = "bzl_srcs", + srcs = glob(["*.bzl"]), +) diff --git a/tools/windows/windows_config.bzl b/tools/windows/windows_config.bzl new file mode 100644 index 00000000000000..8f6a3d95af5307 --- /dev/null +++ b/tools/windows/windows_config.bzl @@ -0,0 +1,33 @@ +# Copyright 2022 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Rules to create windows configurations""" + +def create_windows_host_config(name = "windows_host_config"): + native.config_setting( + name = "host_windows_x64_constraint", + values = {"host_cpu": "x64_windows"}, + ) + + native.config_setting( + name = "host_windows_arm64_constraint", + values = {"host_cpu": "arm64_windows"}, + ) + + conditions = select({ + "host_windows_arm64_constraint": "host_windows_arm64_constraint", + "//conditions:default": "host_windows_x64_constraint", + }) + + native.alias(name = "host_windows", actual = conditions, visibility = ["//visibility:public"])