-
-
Notifications
You must be signed in to change notification settings - Fork 237
feat: cross-compile to windows msvc #390
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
base: master
Are you sure you want to change the base?
Conversation
Some features of this file doesn't seem to have ever been used under Windows. E.g. the --sysroot flag when compiling with msvc doesn't exist. Also, it was not supported for the user to provide a sysroot anyways.
This allows for picking clang-cl instead of clang.
This should be temporary while I don't combine the wrapper for all platforms.
It's been a few years that lld is not experimental anymore. The advantage of always using lld is that we don't need to make assumptions about cross-compiling.
The library is not called stdc++, the same way libc++ is not called c++.
Because we now renamed "stdc++" to "libstdc++", we don't need to hardcode the stdlib name inside the conditional blocks.
@fmeum, any thoughts? |
I generally like this a lot and can review when you think it's ready. We should strive to make the change in a way that somewhat obviously doesn't change command lines for non-Windows target platforms. |
I was about to put up a very similar implementation. With a couple key differences.
I would be interested in combining efforts. |
@kkass Any chance you can share your working copy (either as repo/branch link or PR on this repo)? |
So, I had this code on my computer for a long time. I found it and wanted to share it with the community. It's not ready for a thorough review, but I wanted to spark a discussion about whether such a thing is desirable.
My motivation is simple: I don't want to have a Windows machine, much less one for development, but I want to distribute my software to run on Windows machines.
To accomplish this, I untangled some code around cross-compilation, which should also pave the way to cross-compile targeting macOS.
If we don't make any assumptions about whether we are cross-compiling, we can have a single pipeline for the targets. E.g. exec Linux or macOS targeting Linux should have no difference in which tools are used to compile and link.
Notice that my code only uses the lld already in the downloaded toolchain.
One way to obtain the Windows sysroot is by using https://github.com/Jake-Shadle/xwin. At this point, I didn't give the search paths much thought and instead hard-coded the directories I had on my sysroot.
A very important piece of this puzzle is adding the
windows_cc_toolchain_config.bzl
file with a few fixes you can see here and here. What I had to change makes me believe that nobody has ever tried to set a Windows sysroot using msvc under Bazel. There's no way the originalwindows_cc_toolchain_config.bzl
could have worked with a sysroot. It's also possible that I am missing something...I hope to get some feedback, and I'm happy to answer any questions you may have.