You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compiling non-x64 for Windows through Bazel is broken. This is necessary to do testing for other architectures on Windows. This probably changed when we removed the ability to compile with the EWDK. The EWDK toolchain previously supported cross compilation. The cross compilation platform defintions here are broken somehow with the "normal" Bazel tool-chain resolution:
➜ rad build --win_arm64
ERROR: C:/users/jxy/_bazel_jxy/ytddry7e/external/bazel_tools/tools/cpp/BUILD:58:19: in cc_toolchain_alias rule @@bazel_tools//tools/cpp:current_cc_toolchain:
Traceback (most recent call last):
File "/virtual_builtins_bzl/common/cc/cc_toolchain_alias.bzl", line 26, column 48, in _impl
File "/virtual_builtins_bzl/common/cc/cc_helper.bzl", line 219, column 17, in _find_cpp_toolchain
Error in fail: Unable to find a CC toolchain using toolchain resolution. Target: @@bazel_tools//tools/cpp:current_cc_toolchain, Platform: @@//:windows_arm64, Exec platform: @@local_config_platform//:host
ERROR: C:/users/jxy/_bazel_jxy/ytddry7e/external/bazel_tools/tools/cpp/BUILD:58:19: Analysis of target '@@bazel_tools//tools/cpp:current_cc_toolchain' failed
ERROR: C:/users/jxy/source/repos/archonitelabs/radiant-cpp/test/BUILD.bazel:20:8: errors encountered resolving select() keys for //test:all_test14
ERROR: Analysis of target '//test:all_test14' failed; build aborted
INFO: Elapsed time: 0.479s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
2024-04-26 11:02:03 ERROR build failed!
Interestingly an ARM64 host resolves the default host tool-chain to x64 and outputs x64 binaries instead of ARM64. This seems like a bug in the MSVC Bazel tool-chain?
On my x64 host:
➜ bazel build --toolchain_resolution_debug=.* --platforms=:windows_arm64 //...
INFO: ToolchainResolution: Target platform //:windows_arm64: Selected execution platform @@local_config_platform//:host,
INFO: ToolchainResolution: Performing resolution of @@bazel_tools//tools/cpp:toolchain_type for target platform //:windows_arm64
ToolchainResolution: Rejected toolchain @@bazel_tools~cc_configure_extension~local_config_cc//:cc-compiler-armeabi-v7a; mismatching values: armv7, android
ToolchainResolution: Rejected toolchain @@bazel_tools~cc_configure_extension~local_config_cc//:cc-compiler-x64_windows; mismatching values: x86_64
ToolchainResolution: Rejected toolchain @@bazel_tools~cc_configure_extension~local_config_cc//:cc-compiler-armeabi-v7a; mismatching values: armv7, android
ToolchainResolution: Rejected toolchain @@bazel_tools~cc_configure_extension~local_config_cc//:cc-compiler-x64_windows; mismatching values: x86_64
ToolchainResolution: Rejected toolchain @@local_config_cc//:cc-compiler-armeabi-v7a; mismatching values: armv7, android
ToolchainResolution: Rejected toolchain @@local_config_cc//:cc-compiler-x64_windows; mismatching values: x86_64
ToolchainResolution: No @@bazel_tools//tools/cpp:toolchain_type toolchain found for target platform //:windows_arm64.
INFO: ToolchainResolution: Target platform //:windows_arm64: Selected execution platform @@local_config_platform//:host,
ERROR: C:/users/jxy/_bazel_jxy/ytddry7e/external/bazel_tools/tools/cpp/BUILD:58:19: in cc_toolchain_alias rule @@bazel_tools//tools/cpp:current_cc_toolchain:
Traceback (most recent call last):
File "/virtual_builtins_bzl/common/cc/cc_toolchain_alias.bzl", line 26, column 48, in _impl
File "/virtual_builtins_bzl/common/cc/cc_helper.bzl", line 219, column 17, in _find_cpp_toolchain
Error in fail: Unable to find a CC toolchain using toolchain resolution. Target: @@bazel_tools//tools/cpp:current_cc_toolchain, Platform: @@//:windows_arm64, Exec platform: @@local_config_platform//:host
ERROR: C:/users/jxy/_bazel_jxy/ytddry7e/external/bazel_tools/tools/cpp/BUILD:58:19: Analysis of target '@@bazel_tools//tools/cpp:current_cc_toolchain' failed
ERROR: C:/users/jxy/source/repos/archonitelabs/radiant-cpp/test/BUILD.bazel:28:8: errors encountered resolving select() keys for //test:all_test17
ERROR: Analysis of target '//test:all_test17' failed; build aborted
INFO: Elapsed time: 0.703s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
Seems like a bug in Bazel tool-chain resolution for a standard MSVC (Visual Studio) install. A workaround might be manually activating the build environment before triggering Bazel tool-chain resolution:
Specifying a platform to build should cross-compile for that architecture for Windows. Not specifying an architecture should build using the native host tool-chain.
Actual behavior (optional)
Compilation fails if you try to cross compile. On an ARM64 host the located tool-chain is x64 and chooses the x64 target, so you end up with a x64 binary instead of the intended native ARM64 one.
Environment (optional)
Windows x64 and ARM64
Bazel MSVC
The text was updated successfully, but these errors were encountered:
This is at least a regression in Bazel. And at worst the platforms constraints never worked correctly - I have submitted a bug to Bazel: bazelbuild/bazel#22164
In the meantime, I have implemented bzlmod support in the EWDK toolchain repo. That will allow us to re-integrate with EWDK toolchain resolution as a workaround: 0xf005ba11/bazel_ewdk_cc#1
I will be putting together a PR on this repo to provide a workaround. Hopefully Bazel can address the problem or advise on another solution.
Brief description of your issue
Compiling non-x64 for Windows through Bazel is broken. This is necessary to do testing for other architectures on Windows. This probably changed when we removed the ability to compile with the EWDK. The EWDK toolchain previously supported cross compilation. The cross compilation platform defintions here are broken somehow with the "normal" Bazel tool-chain resolution:
radiant-cpp/BUILD.bazel
Lines 45 to 79 in e32b683
Steps to reproduce (optional)
On an x64 or ARM64 Windows host:
Interestingly an ARM64 host resolves the default host tool-chain to x64 and outputs x64 binaries instead of ARM64. This seems like a bug in the MSVC Bazel tool-chain?
On my x64 host:
Seems like a bug in Bazel tool-chain resolution for a standard MSVC (Visual Studio) install. A workaround might be manually activating the build environment before triggering Bazel tool-chain resolution:
Expected behavior (optional)
Specifying a platform to build should cross-compile for that architecture for Windows. Not specifying an architecture should build using the native host tool-chain.
Actual behavior (optional)
Compilation fails if you try to cross compile. On an ARM64 host the located tool-chain is x64 and chooses the x64 target, so you end up with a x64 binary instead of the intended native ARM64 one.
Environment (optional)
The text was updated successfully, but these errors were encountered: