-
Notifications
You must be signed in to change notification settings - Fork 406
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
Adding basic windows support #329
Conversation
I had the change for more than a month, in the meantime this got added: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi sounds great to start seeing Windows support along. We have a lot of unixism in this repository though.
Would this be possible to add windows support to the CI too? You need to edit .bazelci/presubmit.yml, you can get the syntax of the file there.
rust/private/rust.bzl
Outdated
output = ctx.actions.declare_file(ctx.label.name + ".wasm") | ||
else: | ||
output = ctx.actions.declare_file(ctx.label.name) | ||
output = ctx.actions.declare_file(ctx.label.name + toolchain.binary_ext) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am surprised WASM test still pass as there is no declared extension corresponding: https://github.com/jelmansouri/rules_rust/blob/win_support/rust/platform/triple_mappings.bzl#L39
I don't really understand the WASM change though so I cannot tell if its missing tests or because the extension is not important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I have a couple changes coming up after to not use run_shell in the subset of rules we are using. (cc_library and cc_binary). Similarly to this change we did on go:
https://github.com/bazelbuild/rules_go/blob/master/go/private/rules/binary.bzl#L120
It's a great thing to add the CI and I'm really happy to do it!
Our goal is not to rely on genrules nor run_shell on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what is using the Windows CI to fail is the use of run_shell, my other that I did in our codebase to not use run_shell, needs to be redone given that the command used to run the compiler is gotten more complicated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Submitted some WIP to have a green CI, do you think it's ok if I get a similar change as in the go rule linked above in the function I added (will need to shuffle stuff around)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is fine. I also prefer genrule over run_shell as the later needs a posix shell.
I don't think it is broken, at least the CI is green. |
The change has two parts to it: Note that C++ has been chosen to not introduce more dependencies (a cc toolchain is necessary anyways to build rust code), there is a similar wrapper written in python for protoc, I'm planning to migrate it to rust or C++. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The structure of the change looks good I think this is the correct direction, do you mind splitting this in 3 PR though?
- The c++ wrapper tool
- The cargo build script wrapper change
- The rule change to support windows
?
Thanks!
The c++ wrapper tool and the cargo build script wrapper change are hard to split, since the wrapper consumes the files generated by it, and I had to do small changes to the format of the output files. |
I think we are on the same page. Let me try to rephrase a bit how I see the 3 independent changes:
Depending on your preference you can include the drop of the tar file support in the C++ wrapper or as a separate change (it make sense to put it with the C++ wrapper as this comes with the reason for it). Dropping the support is just calling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some nits left, thanks a lot for following through for this change, very nice addition!
- "--enable_runfiles" # this is not enabled by default on windows and is necessary for the cargo build scripts | ||
windows_targets: &windows_targets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we plan to have multiple windows run? Maybe there is no need for the windows_targets indirection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's to add test_targets, I'm still trying to fix rustdoct_test rules to be able to add them. But I prefer the change to go in first without this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok no worries, I am going to merge this PR as-is this is already a huge improvement over the status-quo.
rust/platform/triple_mappings.bzl
Outdated
"windows": ".exe", | ||
"darwin": "", | ||
# TODO(acmcarther): To be verified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this TODO, darwin extension is definitely empty.
# TODO(acmcarther): To be verified |
rust/platform/triple_mappings.bzl
Outdated
"windows": ".dll", | ||
# TODO(acmcarther): To be verified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
# TODO(acmcarther): To be verified |
rust/platform/triple_mappings.bzl
Outdated
"windows": ".lib", | ||
# TODO(acmcarther): To be verified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem
# TODO(acmcarther): To be verified |
It failed to parse empty depenv files due to how 'split' function works.
Adding binary extension support to the rust_binary rule, this allows us to build on windows.