-
Notifications
You must be signed in to change notification settings - Fork 435
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
Multiple proto generation/linking causing compilation issue #300
Comments
And I should note that I see this same issue at master as well, the commits are the result of a bisect. |
+1, seeing the same issue when building in bin/ directory using commit 7cde1e4 |
Following up with this, commenting out these two sections in //rust/private/rust.bzl removes the problem. A similar strategy of commenting out this section and this line works on master. |
Seems like the same problem described in #294 |
@colinmerkel-th thanks for pointing that out. I didn't think to look into PRs. That's a much cleaner example. |
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
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
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.
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.
I've tried to put a minimally reproducible example of the problem I was running into here
When going from commit 5c0e90a to commit 7cde1e46, via #240, I was getting compilation errors, of
when importing a server implementation from another file that's trying to create a gRPC/protobuf server. This is using the rust_library, rust_executable, proto_library, and rust_grpc_library rules.
The compilation between those two different commits seems nearly identical, but in the failing case, the
SUBCOMMAND: # //proto:echo_proto
seems to be run twice, and then linked into the executable twice.I'm new to rust. Is this something incorrect in that workspace setup, or is something else going wrong?
The text was updated successfully, but these errors were encountered: