diff --git a/Cargo.toml b/Cargo.toml index 33211ea7..9a4f660b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,3 +13,9 @@ members = [ "rustler_tests/native/rustler_compile_tests", "rustler_benchmarks/native/benchmark", ] +default-members = [ + "rustler", + "rustler_bigint", + "rustler_codegen", + "rustler_sys", +] diff --git a/rustler/Cargo.toml b/rustler/Cargo.toml index be578b4d..5026f843 100644 --- a/rustler/Cargo.toml +++ b/rustler/Cargo.toml @@ -9,7 +9,7 @@ readme = "../README.md" edition = "2021" [features] -default = ["derive", "nif_version_2_15", "allocator"] +default = ["derive", "nif_version_2_15"] derive = ["rustler_codegen"] alternative_nif_init_name = [] allocator = [] diff --git a/rustler/src/alloc.rs b/rustler/src/alloc.rs index 1ee48825..92099a92 100644 --- a/rustler/src/alloc.rs +++ b/rustler/src/alloc.rs @@ -1,5 +1,9 @@ use std::alloc::{GlobalAlloc, Layout}; +#[cfg(feature = "allocator")] +#[global_allocator] +static ALLOCATOR: EnifAllocator = EnifAllocator; + /// Allocator implementation that forwards all allocation calls to Erlang's allocator. Allows the /// memory usage to be tracked by the BEAM. pub struct EnifAllocator; diff --git a/rustler/src/lib.rs b/rustler/src/lib.rs index 82b52517..94b5f321 100644 --- a/rustler/src/lib.rs +++ b/rustler/src/lib.rs @@ -30,11 +30,6 @@ pub mod wrapper; pub mod codegen_runtime; mod alloc; -pub use alloc::EnifAllocator; - -#[cfg(feature = "allocator")] -#[global_allocator] -static ALLOCATOR: EnifAllocator = EnifAllocator; pub use lazy_static; diff --git a/rustler_tests/native/deprecated_macros/Cargo.toml b/rustler_tests/native/deprecated_macros/Cargo.toml index 39b6c5c1..f487b144 100644 --- a/rustler_tests/native/deprecated_macros/Cargo.toml +++ b/rustler_tests/native/deprecated_macros/Cargo.toml @@ -10,4 +10,4 @@ path = "src/lib.rs" crate-type = ["cdylib"] [dependencies] -rustler = { path = "../../../rustler" } +rustler = { path = "../../../rustler", features = ["allocator"]} diff --git a/rustler_tests/native/dynamic_load/Cargo.toml b/rustler_tests/native/dynamic_load/Cargo.toml index 469596ea..06c29784 100644 --- a/rustler_tests/native/dynamic_load/Cargo.toml +++ b/rustler_tests/native/dynamic_load/Cargo.toml @@ -10,4 +10,4 @@ crate-type = ["cdylib"] [dependencies] rustler_bigint = { path = "../../../rustler_bigint" } -rustler = { path = "../../../rustler" } \ No newline at end of file +rustler = { path = "../../../rustler", features = ["allocator"] } diff --git a/rustler_tests/native/rustler_bigint_test/Cargo.toml b/rustler_tests/native/rustler_bigint_test/Cargo.toml index 79960355..da9fa435 100644 --- a/rustler_tests/native/rustler_bigint_test/Cargo.toml +++ b/rustler_tests/native/rustler_bigint_test/Cargo.toml @@ -10,4 +10,4 @@ crate-type = ["cdylib"] [dependencies] rustler_bigint = { path = "../../../rustler_bigint" } -rustler = { path = "../../../rustler" } +rustler = { path = "../../../rustler", features = ["allocator"] } diff --git a/rustler_tests/native/rustler_compile_tests/Cargo.toml b/rustler_tests/native/rustler_compile_tests/Cargo.toml index 7db15519..a3f6aa1c 100644 --- a/rustler_tests/native/rustler_compile_tests/Cargo.toml +++ b/rustler_tests/native/rustler_compile_tests/Cargo.toml @@ -11,4 +11,4 @@ crate-type = ["cdylib"] [dependencies] lazy_static = "1.4" -rustler = { path = "../../../rustler" } +rustler = { path = "../../../rustler", features = ["allocator"] } diff --git a/rustler_tests/native/rustler_test/Cargo.toml b/rustler_tests/native/rustler_test/Cargo.toml index dc341923..24899c9b 100644 --- a/rustler_tests/native/rustler_test/Cargo.toml +++ b/rustler_tests/native/rustler_test/Cargo.toml @@ -21,4 +21,4 @@ nif_version_2_17 = ["nif_version_2_16", "rustler/nif_version_2_17"] [dependencies] lazy_static = "1.4" -rustler = { path = "../../../rustler" } +rustler = { path = "../../../rustler", features = ["allocator"] }