Skip to content

FR: Add rust_wasm_library #771

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

Open
UebelAndre opened this issue Jun 17, 2021 · 5 comments
Open

FR: Add rust_wasm_library #771

UebelAndre opened this issue Jun 17, 2021 · 5 comments

Comments

@UebelAndre
Copy link
Collaborator

There appears to be a desire for something like this which stems from #312

An insightful bit of context can be found in #240 (comment) but essentially, it seems to be rust_binary is being used in some (now) wasm edge cases but instead, we should probably have a more first class rule for supporting these cases?

I came across this while trying to understand #604 which at first glance just seems to be a quick solution to unblock a larger set of functionality but could ultimately stand to be re-reviewed.

@PiotrSikora
Copy link
Contributor

PiotrSikora commented Jun 25, 2021

@UebelAndre
Copy link
Collaborator Author

@PiotrSikora Could you reiterate why the rust_library target needs to return an executable? It seems like you should be able to grab the file from CrateInfo::output. Could that be used in place of out_binary?

@PiotrSikora
Copy link
Contributor

@PiotrSikora Could you reiterate why the rust_library target needs to return an executable? It seems like you should be able to grab the file from CrateInfo::output. Could that be used in place of out_binary?

Bazel won't even build library with .wasm extension, see this #626 (comment).

@UebelAndre
Copy link
Collaborator Author

Bazel won't even build library with .wasm extension, see this #626 (comment).

Sounds like you're referring to this?

Traceback (most recent call last):
        File ".../rules_rust/rust/private/rust.bzl", line 179, column 32, in _rust_shared_library_impl
                return _rust_library_common(ctx, "cdylib")
        File ".../rules_rust/rust/private/rust.bzl", line 221, column 32, in _rust_library_common
                return rustc_compile_action(
        File ".../rules_rust/rust/private/rustc.bzl", line 614, column 29, in rustc_compile_action
                return establish_cc_info(ctx, crate_info, toolchain, cc_toolchain, feature_configuration) + [
        File ".../rules_rust/rust/private/rustc.bzl", line 671, column 59, in establish_cc_info
                library_to_link = cc_common.create_library_to_link(
Error in create_library_to_link: 'libhello_world-665202032.wasm' does not have any of the allowed extensions .so, .dylib or .dll

If so I feel like that's part of the work that would need to be done to create some rust_wasm_* rules. But is this the basis for why wasm targets should be *_binary targets? That's the bit that's not necessarily clear to me. To me *_binary means you'd expect to pass the file to some thing else as an executable but is that true of all .wasm files?

@roman-kashitsyn
Copy link
Contributor

I'd love to see this implemented as well.

My use-case: I want to build a Wasm module and pass it as input into a test that instantiates the Wasm module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants