diff --git a/Cargo.toml b/Cargo.toml index e888541c..2c2bbadc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,3 +12,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 4547702e..f18def54 100644 --- a/rustler/Cargo.toml +++ b/rustler/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" [features] big_integer = ["dep:num-bigint"] -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 2cfde8d1..b3eaa222 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 4cc7c5d1..126263b3 100644 --- a/rustler_tests/native/dynamic_load/Cargo.toml +++ b/rustler_tests/native/dynamic_load/Cargo.toml @@ -9,4 +9,4 @@ path = "src/lib.rs" crate-type = ["cdylib"] [dependencies] -rustler = { path = "../../../rustler", features = ["big_integer"] } +rustler = { path = "../../../rustler", features = ["big_integer", "allocator"] } diff --git a/rustler_tests/native/rustler_bigint_test/Cargo.toml b/rustler_tests/native/rustler_bigint_test/Cargo.toml index 9f64a529..47374e85 100644 --- a/rustler_tests/native/rustler_bigint_test/Cargo.toml +++ b/rustler_tests/native/rustler_bigint_test/Cargo.toml @@ -9,4 +9,4 @@ path = "src/lib.rs" crate-type = ["cdylib"] [dependencies] -rustler = { path = "../../../rustler", features = ["big_integer"] } +rustler = { path = "../../../rustler", features = ["big_integer", "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"] }