Skip to content
13 changes: 11 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library")

config_setting(
name = "wasm",
values = {
"platforms": "@io_bazel_rules_rust//rust/platform:wasm",
},
)

rust_library(
name = "proxy_wasm",
srcs = glob(["src/*.rs"]),
Expand All @@ -8,6 +15,8 @@ rust_library(
deps = [
"//bazel/cargo:hashbrown",
"//bazel/cargo:log",
"//bazel/cargo:wee_alloc",
],
] + select({
":wasm": ["//bazel/cargo:wee_alloc"],
"//conditions:default": [],
}),
)
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ edition = "2018"
[dependencies]
hashbrown = { version = "0.8", default-features = false, features = ["ahash", "inline-more"] }
log = "0.4"
wee_alloc = "0.4"
wee_alloc = { version = "0.4", optional = true }

[features]
wee-alloc = ["wee_alloc"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you move [features] before [dependencies]?


[dev-dependencies]
chrono = "0.4"
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod hostcalls;
pub mod traits;
pub mod types;

#[cfg(feature = "wee-alloc")]
mod allocator;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You need to move this to src/allocator.rs and guard only #[global_allocator]. Having this guard here removes malloc() export.

mod dispatcher;
mod logger;
Expand Down