Skip to content

Commit 76c4420

Browse files
PiotrSikorahlopko
andauthored
Re-add support for building Wasm libraries as executables. (#626)
* Re-add support for building Wasm libraries as executables. The ability to build Wasm libraries as executables is needed to support WASI reactors (Wasm executables with multiple entrypoints). This is a temporary workaround, and we should be able to use crate-type "bin" when a proper support for WASI reactors (rust-lang/rust#79997) is stabilised is Rust. This feature was added in #312, and most recently broken in #592. Signed-off-by: Piotr Sikora <[email protected]> * review: sort. Signed-off-by: Piotr Sikora <[email protected]> Co-authored-by: Marcel Hlopko <[email protected]>
1 parent 40a8c9e commit 76c4420

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

rust/private/rust.bzl

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@ def _rust_binary_impl(ctx):
255255
return rustc_compile_action(
256256
ctx = ctx,
257257
toolchain = toolchain,
258-
crate_type = "bin",
258+
crate_type = ctx.attr.crate_type,
259259
crate_info = rust_common.crate_info(
260260
name = crate_name,
261-
type = "bin",
262-
root = crate_root_src(ctx.attr, ctx.files.srcs, crate_type = "bin"),
261+
type = ctx.attr.crate_type,
262+
root = crate_root_src(ctx.attr, ctx.files.srcs, ctx.attr.crate_type),
263263
srcs = depset(ctx.files.srcs),
264264
deps = depset(ctx.attr.deps),
265265
proc_macro_deps = depset(ctx.attr.proc_macro_deps),
@@ -793,6 +793,15 @@ rust_proc_macro = rule(
793793
)
794794

795795
_rust_binary_attrs = {
796+
"crate_type": attr.string(
797+
doc = _tidy("""
798+
Crate type that will be passed to `rustc` to be used for building this crate.
799+
800+
This option is a temporary workaround and should be used only when building
801+
for WebAssembly targets (//rust/platform:wasi and //rust/platform:wasm).
802+
"""),
803+
default = "bin",
804+
),
796805
"linker_script": attr.label(
797806
doc = _tidy("""
798807
Link script to forward into linker via rustc options.

0 commit comments

Comments
 (0)