Skip to content

Support building 32-bit C++ binaries on Windows with MSVC toolchain#11938

Closed
mai12 wants to merge 9 commits into
bazelbuild:masterfrom
mai12:mai12-patch-1
Closed

Support building 32-bit C++ binaries on Windows with MSVC toolchain#11938
mai12 wants to merge 9 commits into
bazelbuild:masterfrom
mai12:mai12-patch-1

Conversation

@mai12

@mai12 mai12 commented Aug 13, 2020

Copy link
Copy Markdown
Contributor

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

mai12 added 2 commits August 13, 2020 12:04
@meteorcloudy meteorcloudy self-requested a review August 13, 2020 11:13
@meteorcloudy

Copy link
Copy Markdown
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 ;)

@meteorcloudy meteorcloudy left a comment

Copy link
Copy Markdown
Member

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? 😃

Comment thread tools/cpp/windows_cc_configure.bzl Outdated
@meteorcloudy

Copy link
Copy Markdown
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

Comment thread tools/cpp/BUILD.windows.tpl
@mai12 mai12 changed the title Adding support for compiling 32-bit binaries Support 32-bit c++ windows toolchain Aug 14, 2020
Comment thread tools/cpp/windows_cc_configure.bzl Outdated
@googlebot

Copy link
Copy Markdown

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
Copy Markdown
Member

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

@meteorcloudy

Copy link
Copy Markdown
Member

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

@mai12

mai12 commented Aug 14, 2020

Copy link
Copy Markdown
Contributor Author

@googlebot I fixed it.

1 similar comment
@mai12

mai12 commented Aug 14, 2020

Copy link
Copy Markdown
Contributor Author

@googlebot I fixed it.

@googlebot

Copy link
Copy Markdown

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Comment thread tools/cpp/windows_cc_configure.bzl
Comment thread src/test/py/bazel/bazel_windows_cpp_test.py
Comment thread tools/cpp/windows_cc_configure.bzl
@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