Ar/cor 2473 implement a default allocator for concordium std on wasm32 - #478
Conversation
| //! contracts. For this reason it re-exports a number of definitions from other | ||
| //! libraries. | ||
| //! | ||
| //! # Versions |
There was a problem hiding this comment.
Moved to the end of the documentation
…ust-smart-contracts into ar/cor-2473-implement-a-default-allocator-for-concordium-std-on-wasm32
| # cdylib is needed below to compile into a wasm module with internal unit tests. | ||
| crate-type = ["cdylib", "rlib"] | ||
| # Set a global allocator. Otherwise, it must be set in smart contract. | ||
| global_alloc = [] |
There was a problem hiding this comment.
Not sure when this feature is useful? Would the user ever want to disable default features and then enable just global_alloc alone? or any of the allocators without having global_alloc as well?
To me there seems to be 3 choices,
- none of the allocators enabled (disable default features)
dlmallocbump_alloc
There was a problem hiding this comment.
The combination I thought of was enabling bump_alloc but wanting to set it as global allocator yourself. The features dlmalloc and bump_alloc are truly additive, the global_alloc feature is not really additive (https://doc.rust-lang.org/cargo/reference/features.html#feature-unification). That can especially be relevant if you have several smart contracts in the same workspace. But it may be simpler not to have the feaute.
There was a problem hiding this comment.
Removed global_alloc feature, bump_alloc module is now compiled on WASM32 unconditionally
Purpose
Set dlmalloc as the default allocator. It was default when compiling to https://doc.rust-lang.org/rustc/platform-support/wasm32-unknown-unknown.html with std library.
Changes
dlmallocis defaultbump_allocfeature enabledbump_allocglobal_allocis default and sets the global allocatorconcordium_stdlib.rsdocs for this change and the previous changes forwasm32v1featureconcordium-stdif it must be compilable without theglobal_allocfeatureChecklist
hard-to-understand areas.