Skip to content

use -msvc variant on Windows #425

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

Merged
merged 1 commit into from
Oct 16, 2020

Conversation

dae
Copy link
Contributor

@dae dae commented Oct 11, 2020

use -msvc variant on Windows

Both the standard Rust installer, and rust_repositories() in this repo
default to the -msvc platform. Since it is the default on Windows,
this change comments out the -gnu variant instead.

This change (along with some fixes in cargo raze) allows crates with
msvc-specific build deps to compile. I do not know enough about Bazel
to say if it will have any unintended side effects, but it seems to
work for me, and allows a moderate sized project with about 250
crate dependencies to compile using the default toolchain.

@google-cla google-cla bot added the cla: yes label Oct 11, 2020
@dae dae marked this pull request as ready for review October 11, 2020 11:01
dae added a commit to ankitects/cargo-raze that referenced this pull request Oct 13, 2020
Without an explicit list of targets,
@io_bazel_rules_rust//rust/platform:x86_64-pc-windows-msvc is also
included, and that is not currently supported by io_bazel_rules_rust.
While this change fixes the build, it's probably best to wait for
the outcome of bazelbuild/rules_rust#425,
since if it changes there, a better solution would be to remove the
-gnu variants from SUPPORTED_PLATFORM_TRIPLES in impl/src/bazel.rs
@dae
Copy link
Contributor Author

dae commented Oct 13, 2020

I experimented with enabling both -gnu and -msvc variants, and using a constraint setting to switch between them. This avoids the "Illegal ambiguous match on configurable attribute deps" errors that arise when both the -gnu variant and -msvc variant are listed in a crate's dependencies. I wasn't able to figure out how this could be made a default though, and if that's not possible, it means Windows users would need to define the environment they wish to use in their BUILD file, eg

platform(
    name = "x86_64-windows-gnu",
    constraint_values = [
        "@platforms//cpu:x86_64",
        "@platforms//os:windows",
        "@io_bazel_rules_rust//rust/platform/env:gnu",
    ],
)

and then specify the platform when compiling:

bazel build //some:target --platforms=x86_64-windows-gnu --host_platform=x86-windows-gnu

This is a bit of a pain, but then it's already necessary to pass -enable_runfiles in on Windows in order to get crate buildscripts to compile. Thoughts?

@damienmg
Copy link
Collaborator

I think commenting out the gnu version is preferable.

@damienmg damienmg self-requested a review October 16, 2020 09:36
Both the standard Rust installer, and rust_repositories() in this repo
default to the -msvc platform. Since it is the default on Windows,
this change comments out the -gnu variant instead.

This change (along with some fixes in cargo raze) allows crates with
msvc-specific build deps to compile. I do not know enough about Bazel
to say if it will have any unintended side effects, but it seems to
work for me.
@dae dae force-pushed the default-to-msvc-on-windows branch from 5e9f1bc to f2b9a04 Compare October 16, 2020 10:00
@dae
Copy link
Contributor Author

dae commented Oct 16, 2020

Sorry, I had thought I'd commented out the other set already - corrected.

@damienmg
Copy link
Collaborator

Thanks!

@UebelAndre
Copy link
Collaborator

@damienmg @dae Hey, this seems to have broken CI. Would one of you guys mind taking a look?

@UebelAndre
Copy link
Collaborator

It looks like cargo-raze will need to be updated and these outputs will need to be regenerated 😞 or a list of targets will need to be added to exclude the windows -gnu platform declarations.

@UebelAndre
Copy link
Collaborator

I have a fix in #450

@UebelAndre
Copy link
Collaborator

Just an FYI: bazelbuild/platforms#38 may potentially lead to support for both -msvc and -gnu

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.

3 participants