Skip to content

Commit ff451b1

Browse files
committed
Remove the global_alloc feature`
1 parent 2747a22 commit ff451b1

2 files changed

Lines changed: 8 additions & 17 deletions

File tree

concordium-std/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ default-features = false
2222
features = ["smart-contract"]
2323

2424
[features]
25-
default = ["dlmalloc", "global_alloc"]
25+
default = ["dlmalloc"]
2626
# Enabling the wasm-test feature changes the #[concoridum_test] macro to output test functions callable from WASM interpreter
2727
wasm-test = ["concordium-contracts-common/wasm-test"]
2828
# Own internal wasm-tests leak out to the smart contracts using this library,
@@ -38,8 +38,6 @@ debug = []
3838
dlmalloc = ["dep:dlmalloc"]
3939
# Use the custom bump allocator instead of dlmalloc. See module documentation for bump_alloc in this crate.
4040
bump_alloc = []
41-
# Set a global allocator. Otherwise, it must be set in smart contract.
42-
global_alloc = []
4341

4442
[dev-dependencies]
4543
trybuild = "1.0"

concordium-std/src/lib.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919
//! # Features
2020
//!
2121
//! This library has the following features:
22-
//! [`dlmalloc`](#dlmalloc-bump_alloc-and-global_alloc-use-a-custom-allocator),
23-
//! [`bump_alloc`](#dlmalloc-bump_alloc-and-global_alloc-use-a-custom-allocator),
24-
//! [`global_alloc`](#dlmalloc-bump_alloc-and-global_alloc-use-a-custom-allocator), and
22+
//! [`dlmalloc`](#dlmalloc-and-bump_alloc-use-a-custom-allocator),
23+
//! [`bump_alloc`](#dlmalloc-and-bump_alloc-use-a-custom-allocator), and
2524
//! [`debug`](#debug-emit-debug-information).
2625
//! And the following features used by tooling only:
2726
//! [`build-schema`](#build-schema-build-for-generating-a-module-schema) and
2827
//! [`wasm-test`](#wasm-test-build-for-testing-in-wasm),
2928
//!
30-
//! ## `dlmalloc`, `bump_alloc` and `global_alloc`: Use a custom allocator
29+
//! ## `dlmalloc` and `bump_alloc`: Use a custom allocator
3130
//!
3231
//! The default allocator is [`dlmalloc`](https://crates.io/crates/dlmalloc), which
3332
//! is a general purpose allocator. For smart contracts, the lighter `bump_alloc`
@@ -41,8 +40,7 @@
4140
//! tradeoff. Especially for contracts such as those dealing with tokens.
4241
//! For very complex contracts it may be beneficial to run benchmarks to see
4342
//! whether `bump_alloc` is the best option. It is also possible to specify
44-
//! your own allocator by disabling the feature flag `global_alloc`. If the flag
45-
//! is enabled, the `concordium-std` will set the global allocator.
43+
//! your own allocator by not enabling any of the `dlmalloc` and `bump_alloc` features.
4644
//! See the Rust [allocator](https://doc.rust-lang.org/std/alloc/index.html#the-global_allocator-attribute)
4745
//! documentation for more context and details on using custom allocators.
4846
//!
@@ -277,7 +275,7 @@
277275
//! sense to compile it with `no_std`. If you have code that conditionally should only compile
278276
//! when WASM is the target, you can condition on the WASM target: `#[cfg(target_arch = "wasm32")]`.
279277
//!
280-
//! If you are using a custom allocator, see [this section](#dlmalloc-bump_alloc-and-global_alloc-use-a-custom-allocator)
278+
//! If you are using a custom allocator, see [this section](#dlmalloc-and-bump_alloc-use-a-custom-allocator)
281279
//! on how to configure it.
282280
//!
283281
//! ## Version 8.1
@@ -415,20 +413,15 @@ pub use core::{cell, cmp, convert, fmt, hash, hint, iter, marker, mem, num, ops,
415413
#[cfg(all(
416414
feature = "dlmalloc",
417415
not(feature = "bump_alloc"),
418-
feature = "global_alloc",
419416
target_arch = "wasm32"
420417
))]
421418
#[global_allocator]
422419
static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc;
423420

424-
#[cfg(all(feature = "bump_alloc", target_arch = "wasm32"))]
421+
#[cfg(target_arch = "wasm32")]
425422
pub mod bump_alloc;
426423

427-
#[cfg(all(
428-
feature = "bump_alloc",
429-
feature = "global_alloc",
430-
target_arch = "wasm32"
431-
))]
424+
#[cfg(all(feature = "bump_alloc", target_arch = "wasm32"))]
432425
#[global_allocator]
433426
static ALLOC: bump_alloc::BumpAllocator = unsafe { bump_alloc::BumpAllocator::new() };
434427

0 commit comments

Comments
 (0)