Open jxy-s opened 2 months ago
This is at least a regression in Bazel. And at worst the platforms constraints never worked correctly - I have submitted a bug to Bazel: https://github.com/bazelbuild/bazel/issues/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: https://github.com/0xf005ba11/bazel_ewdk_cc/pull/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.
I've tracked down another problem in bazelisk that explains the problem with trying to compile natively on ARM64: https://github.com/bazelbuild/bazelisk/issues/572 https://github.com/bazelbuild/bazel/issues/22164#issuecomment-2081383179
I've implemented the workaround for cross compiling here: https://github.com/archonitelabs/radiant-cpp/pull/9
Keeping this open for tracking the issues brought to Bazel and for visibility.
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: https://github.com/archonitelabs/radiant-cpp/blob/e32b6839c9a9be11a34fdb4c9643319a3f27a87b/BUILD.bazel#L45-L79
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)