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 32-bit C++ binaries on Windows with MSVC toolchain #11938

Closed
wants to merge 9 commits into from

Conversation

mai12
Copy link
Contributor

@mai12 mai12 commented Aug 13, 2020

This PR will allow Bazel to compile 32-bit c++ build targets on windows. A new cc toolchain (cc-compiler-x64_x86_windows) is added to support compiling 32-bit c++ binaries using MSVC compiler.

To use this toolchain, the --cpu option in the build command needs to be set to x64_x86_windows.

Fixes: #10963
@meteorcloudy

@meteorcloudy meteorcloudy self-requested a review August 13, 2020 11:13
@meteorcloudy
Copy link
Member

Thanks for working on this! A few suggestions first:

  • Can you add a brief description about this PR? What it does, how should user use this new feature?
  • When creating a new commit, it's better to also have a more detailed message as the title instead of only "Support compiling 32-bit binaries". It will make it easier to review ;)

Copy link
Member

@meteorcloudy meteorcloudy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is real nice implementation! Thanks!
Can you add the test? 😃

tools/cpp/windows_cc_configure.bzl Outdated Show resolved Hide resolved
@meteorcloudy
Copy link
Member

flags = ["/MACHINE:X64"],

Another /MACHINE:X64 is hard coded in windows_cc_toolchain_config.bzl, you probably need to refactor it as an attribute like the default_link_flags, otherwise the build will fail with:

bazel-out\x64_x86_windows-fastbuild\bin\examples\cpp\_objs\hello-lib\hello-lib.obj : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 
'x64'
Target //examples/cpp:hello-world failed to build

@mai12 mai12 changed the title Adding support for compiling 32-bit binaries Support 32-bit c++ windows toolchain Aug 14, 2020
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@meteorcloudy
Copy link
Member

@mai12 It looks like you committed with a different account? Can you switch back to the same account?

@meteorcloudy
Copy link
Member

I think you can do a force push to override the commits pushed by another account?

@mai12
Copy link
Contributor Author

mai12 commented Aug 14, 2020

@googlebot I fixed it.

1 similar comment
@mai12
Copy link
Contributor Author

mai12 commented Aug 14, 2020

@googlebot I fixed it.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@meteorcloudy meteorcloudy changed the title Support 32-bit c++ windows toolchain Support building 32-bit C++ binaries on Windows with MSVC toolchain Aug 17, 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.

Support 32-bit c++ windows toolchain
4 participants