Skip to content

Add cfg = proc_macro_host_transition to all rules #301

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
Apr 11, 2020

Conversation

dfreese
Copy link
Collaborator

@dfreese dfreese commented Apr 11, 2020

The rust_library rule specifies a cfg option. This performs transitions
in order to support WASM. Other rules, such as rust_binary, do not have
this configuration, which causes Bazel to build and link some libraries
into the final binary twice, resulting in compilation errors. This is
detailed in pull request #294 and issue #300. The issue was introduced
in commit 7cde1e4.

This adds the example from @colin353 in PR #294 as an example that would
otherwise fail.

Fixes #300

The rust_library rule specifies a cfg option.  This performs transitions
in order to support WASM.  Other rules, such as rust_binary, do not have
this configuration, which causes Bazel to build and link some libraries
into the final binary twice, resulting in compilation errors.  This is
detailed in pull request bazelbuild#294 and issue bazelbuild#300.  The issue was introduced
in commit 7cde1e4.

This adds the example from @colin353 in PR bazelbuild#294 as an example that would
otherwise fail.

Fixes bazelbuild#300
@colin353
Copy link
Collaborator

@dfreese thanks for writing this! Looks great!

@mfarrugi mfarrugi merged commit a1d8936 into bazelbuild:master Apr 11, 2020
@dfreese dfreese deleted the fix-cfg branch April 12, 2020 00:57
dfreese added a commit to dfreese/rules_rust that referenced this pull request Apr 20, 2020
This mostly reverts commit a1d8936, removing the
proc_macro_host_transition from most rules.  This fixes bazelbuild#305, by no
longer having a transition on rust_binary.  It still solves bazelbuild#300 by
adding this transition to rust_proto_library and rust_grpc_library.
Those rules are meant to mirror rust_library, so they should share the
same cfg values.  Sharing the same configuration means that
rust_proto_library or rust_grpc_library can be dependencies to
rust_library or rust_binary and not cause another configuration of the
library to be generated.

The example introduced by bazelbuild#301 is moved in this commit into a subfolder
to provide a more clear directory structure.
damienmg pushed a commit that referenced this pull request Apr 21, 2020
This mostly reverts commit a1d8936, removing the
proc_macro_host_transition from most rules.  This fixes #305, by no
longer having a transition on rust_binary.  It still solves #300 by
adding this transition to rust_proto_library and rust_grpc_library.
Those rules are meant to mirror rust_library, so they should share the
same cfg values.  Sharing the same configuration means that
rust_proto_library or rust_grpc_library can be dependencies to
rust_library or rust_binary and not cause another configuration of the
library to be generated.

The example introduced by #301 is moved in this commit into a subfolder
to provide a more clear directory structure.
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.

Multiple proto generation/linking causing compilation issue
4 participants