Skip to content
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

Don't emit CrateInfo from rust_static_library and rust_shared_library #1298

Conversation

scentini
Copy link
Collaborator

@scentini scentini commented Apr 26, 2022

These rules emit a staticlib and cdylib which are not meant for consumption by other rust targets.

However, one should still be able to write a rust_test for rust_shared_library and rust_static_library targets, which needs a CrateInfo. For this purpose we provide a CrateInfo wrapped in a TestCrateInfo provider, that rust_test understands.

@scentini scentini requested a review from hlopko April 27, 2022 12:35
@scentini scentini marked this pull request as ready for review April 27, 2022 12:35
@scentini scentini merged commit 5abeb93 into bazelbuild:main Apr 28, 2022
@scentini scentini deleted the dont_emit_crate_info_from_staticlib_and_cdylib branch April 28, 2022 14:32
DefaultInfo(
# nb. This field is required for cc_library to depend on our output.
files = depset(outputs),
runfiles = runfiles,
executable = crate_info.output if crate_info.type == "bin" or crate_info.is_test or out_binary else None,
),
]

if crate_info.type in ["staticlib", "cdylib"]:
Copy link
Contributor

@PiotrSikora PiotrSikora May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This confuses rule type with crate_info.type, and breaks rust_binary(crate_type="cdylib") which we use when building WebAssembly targets (due to a missing first-class support for rust_wasm_binary()):

[...]
ERROR: /tmp/proxy-wasm-cpp-host/test/test_data/BUILD:45:17: in rust_binary rule //test/test_data:_wasm_env_wasm: 
.../external/rules_rust/rust/private/rust.bzl:295:5: rule advertised the 'CrateInfo' provider, but this provider was not among those returned
ERROR: /tmp/proxy-wasm-cpp-host/test/test_data/BUILD:45:17: Analysis of target '//test/test_data:_wasm_env_wasm' failed
ERROR: Analysis of target '//test/test_data:env.wasm' failed; build aborted: 
[...]

Copy link
Collaborator

@UebelAndre UebelAndre May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PiotrSikora Sorry about the breakage 😞

can you create a separate issue for this? It'd then be good if you could provide a local repro case or maybe just open a PR if you've already got a solution in mind.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a fix (#1315), but local repro is tricky due to a use of custom rule and transition to force build for Wasm.

PiotrSikora added a commit to PiotrSikora/rules_rust that referenced this pull request May 3, 2022
Broken in bazelbuild#1298.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants