Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building C++ binaries for ARM and ARM64 architectures on Windows with MSVC toolchain #11973

Closed
wants to merge 1 commit into from

Conversation

mai12
Copy link
Contributor

@mai12 mai12 commented Aug 19, 2020

This PR will allow Bazel to compile arm and arm64 c++ build targets on windows. New cc toolchains are added to support compiling these binaries using MSVC compiler. These toolchains are cc-compiler-x64_arm_windows and cc-compiler-x64_arm64_windows for building arm and arm64 c++ targets respectively.

To use these toolchains, the --cpu option in the build command needs to be set to their corresponding CPU value.

  • For arm binaries: --cpu=x64_arm_windows
  • For arm64 binaries: --cpu=x64_arm64_windows

@meteorcloudy

@mai12 mai12 marked this pull request as draft August 19, 2020 11:04
@meteorcloudy
Copy link
Member

@mai12 Hi Mai. The arm and arm64 toolchains should be available on CI now. I took a look at the test failures, I think even we don't have the toolchains available, it shouldn't be so many broken tests. Can you take a closer look at what's going on?

tools/cpp/BUILD.windows.tpl Outdated Show resolved Hide resolved
tools/cpp/BUILD.windows.tpl Show resolved Hide resolved
tools/cpp/BUILD.windows.tpl Show resolved Hide resolved
@mai12 mai12 marked this pull request as ready for review August 20, 2020 16:52
@meteorcloudy
Copy link
Member

This is great!

One point I think we can improve is when user try to build with --cpu=x64_arm_windows or --cpu=x64_arm64_windows without the arm toolchains installed. It will fail with the following error:

Execution platform: //:default_host_platform

The target you are compiling requires Visual C++ build tools.
Bazel couldn't find a valid Visual C++ build tools installation on your machine.

Visual C++ build tools seems to be installed at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC
But Bazel can't find the following tools:
    cl.exe, link.exe, lib.exe

Please check your installation following https://docs.bazel.build/versions/master/windows.html#using

Target //examples/cpp:hello-world failed to build

It will be a little confusing for users already have x64 toolchain installed, can we mention the exact toolchain we need in the error message?

Also, we probably want to document those new toolchains at https://docs.bazel.build/versions/master/windows.html#using

@mai12
Copy link
Contributor Author

mai12 commented Aug 21, 2020

yes, I was actually thinking about changing this error message too. Do you think this will be better?

But Bazel can't find the following tools:
cl.exe, link.exe, lib.exe
for {{target_arch}} target architecture.

@meteorcloudy
Copy link
Member

Yes, that sounds good!

@meteorcloudy
Copy link
Member

Nice, can you rebase the PR?

@mai12 mai12 changed the title Support building C++ binaries for 32-bit, ARM and ARM64 architectures on Windows with MSVC toolchain Support building C++ binaries for ARM and ARM64 architectures on Windows with MSVC toolchain Aug 26, 2020
@bazel-io bazel-io closed this in 1f77972 Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants