std: include dlmalloc for all non-wasi Wasm targets#153686
Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom Mar 23, 2026
Merged
std: include dlmalloc for all non-wasi Wasm targets#153686rust-bors[bot] merged 2 commits intorust-lang:mainfrom
std: include dlmalloc for all non-wasi Wasm targets#153686rust-bors[bot] merged 2 commits intorust-lang:mainfrom
Conversation
Currently, building std for a custom Wasm target with an OS other than `unknown` will fail, because `sys/alloc/mod.rs` will attempt to use `sys/alloc/wasm.rs`, the dlmalloc-based allocator used on `wasm32-unknown-unknown`. However, currently dlmalloc is only pulled in when `target_os = "unknown"`. Instead, we should make `Cargo.toml` and `alloc/mod.rs` match: either - disable `wasm.rs` in `alloc/mod.rs` where `not(target_os = "unknown")`, or - pull in `dlmalloc` for all Wasm targets with `target_family = "wasm32"` that aren't covered by the [upper branches of `alloc/mod.rs`](https://github.com/rust-lang/rust/blob/main/library/std/src/sys/alloc/mod.rs#L72-L100). This PR takes the latter approach, because it allows more code to compile without a custom allocator.
Collaborator
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Member
|
|
Contributor
Author
|
Updated so that it is excluded on |
Member
|
@bors r+ rollup=iffy |
Contributor
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Mar 22, 2026
`std`: include `dlmalloc` for all non-wasi Wasm targets Currently, building std for a custom Wasm target with an OS other than `unknown` will fail, because `sys/alloc/mod.rs` will attempt to use `sys/alloc/wasm.rs`, the dlmalloc-based allocator used on `wasm32-unknown-unknown`. However, currently dlmalloc is only pulled in when `target_os = "unknown"`. Instead, we should make `Cargo.toml` and `alloc/mod.rs` match: either - disable `wasm.rs` in `alloc/mod.rs` where `not(target_os = "unknown")`, or - pull in `dlmalloc` for all Wasm targets with `target_family = "wasm32"` that aren't covered by the [upper branches of `alloc/mod.rs`](https://github.com/rust-lang/rust/blob/main/library/std/src/sys/alloc/mod.rs#L72-L100). This PR takes the latter approach, because it allows more code to compile without a custom allocator.
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Mar 22, 2026
`std`: include `dlmalloc` for all non-wasi Wasm targets Currently, building std for a custom Wasm target with an OS other than `unknown` will fail, because `sys/alloc/mod.rs` will attempt to use `sys/alloc/wasm.rs`, the dlmalloc-based allocator used on `wasm32-unknown-unknown`. However, currently dlmalloc is only pulled in when `target_os = "unknown"`. Instead, we should make `Cargo.toml` and `alloc/mod.rs` match: either - disable `wasm.rs` in `alloc/mod.rs` where `not(target_os = "unknown")`, or - pull in `dlmalloc` for all Wasm targets with `target_family = "wasm32"` that aren't covered by the [upper branches of `alloc/mod.rs`](https://github.com/rust-lang/rust/blob/main/library/std/src/sys/alloc/mod.rs#L72-L100). This PR takes the latter approach, because it allows more code to compile without a custom allocator.
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Mar 23, 2026
`std`: include `dlmalloc` for all non-wasi Wasm targets Currently, building std for a custom Wasm target with an OS other than `unknown` will fail, because `sys/alloc/mod.rs` will attempt to use `sys/alloc/wasm.rs`, the dlmalloc-based allocator used on `wasm32-unknown-unknown`. However, currently dlmalloc is only pulled in when `target_os = "unknown"`. Instead, we should make `Cargo.toml` and `alloc/mod.rs` match: either - disable `wasm.rs` in `alloc/mod.rs` where `not(target_os = "unknown")`, or - pull in `dlmalloc` for all Wasm targets with `target_family = "wasm32"` that aren't covered by the [upper branches of `alloc/mod.rs`](https://github.com/rust-lang/rust/blob/main/library/std/src/sys/alloc/mod.rs#L72-L100). This PR takes the latter approach, because it allows more code to compile without a custom allocator.
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Mar 23, 2026
`std`: include `dlmalloc` for all non-wasi Wasm targets Currently, building std for a custom Wasm target with an OS other than `unknown` will fail, because `sys/alloc/mod.rs` will attempt to use `sys/alloc/wasm.rs`, the dlmalloc-based allocator used on `wasm32-unknown-unknown`. However, currently dlmalloc is only pulled in when `target_os = "unknown"`. Instead, we should make `Cargo.toml` and `alloc/mod.rs` match: either - disable `wasm.rs` in `alloc/mod.rs` where `not(target_os = "unknown")`, or - pull in `dlmalloc` for all Wasm targets with `target_family = "wasm32"` that aren't covered by the [upper branches of `alloc/mod.rs`](https://github.com/rust-lang/rust/blob/main/library/std/src/sys/alloc/mod.rs#L72-L100). This PR takes the latter approach, because it allows more code to compile without a custom allocator.
This was referenced Mar 23, 2026
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 23, 2026
…uwer Rollup of 13 pull requests Successful merges: - #154241 (`rust-analyzer` subtree update) - #153686 (`std`: include `dlmalloc` for all non-wasi Wasm targets) - #154105 (bootstrap: Pass `--features=rustc` to rustc_transmute) - #153069 ([BPF] add target feature allows-misaligned-mem-access) - #154085 (Parenthesize or-patterns in prefix pattern positions in pretty printer) - #154191 (refactor RangeFromIter overflow-checks impl) - #154207 (Refactor query loading) - #153540 (drop derive helpers during attribute parsing) - #154140 (Document consteval behavior of ub_checks, overflow_checks, is_val_statically_known.) - #154161 (On E0277 tweak help when single type impls traits) - #154218 (interpret/validity: remove unreachable error kind) - #154225 (diagnostics: avoid ICE in confusable_method_name for associated functions) - #154228 (Improve inline assembly error messages)
github-actions bot
pushed a commit
to rust-lang/stdarch
that referenced
this pull request
Mar 26, 2026
…uwer Rollup of 13 pull requests Successful merges: - rust-lang/rust#154241 (`rust-analyzer` subtree update) - rust-lang/rust#153686 (`std`: include `dlmalloc` for all non-wasi Wasm targets) - rust-lang/rust#154105 (bootstrap: Pass `--features=rustc` to rustc_transmute) - rust-lang/rust#153069 ([BPF] add target feature allows-misaligned-mem-access) - rust-lang/rust#154085 (Parenthesize or-patterns in prefix pattern positions in pretty printer) - rust-lang/rust#154191 (refactor RangeFromIter overflow-checks impl) - rust-lang/rust#154207 (Refactor query loading) - rust-lang/rust#153540 (drop derive helpers during attribute parsing) - rust-lang/rust#154140 (Document consteval behavior of ub_checks, overflow_checks, is_val_statically_known.) - rust-lang/rust#154161 (On E0277 tweak help when single type impls traits) - rust-lang/rust#154218 (interpret/validity: remove unreachable error kind) - rust-lang/rust#154225 (diagnostics: avoid ICE in confusable_method_name for associated functions) - rust-lang/rust#154228 (Improve inline assembly error messages)
github-actions bot
pushed a commit
to rust-lang/rust-analyzer
that referenced
this pull request
Mar 26, 2026
…uwer Rollup of 13 pull requests Successful merges: - rust-lang/rust#154241 (`rust-analyzer` subtree update) - rust-lang/rust#153686 (`std`: include `dlmalloc` for all non-wasi Wasm targets) - rust-lang/rust#154105 (bootstrap: Pass `--features=rustc` to rustc_transmute) - rust-lang/rust#153069 ([BPF] add target feature allows-misaligned-mem-access) - rust-lang/rust#154085 (Parenthesize or-patterns in prefix pattern positions in pretty printer) - rust-lang/rust#154191 (refactor RangeFromIter overflow-checks impl) - rust-lang/rust#154207 (Refactor query loading) - rust-lang/rust#153540 (drop derive helpers during attribute parsing) - rust-lang/rust#154140 (Document consteval behavior of ub_checks, overflow_checks, is_val_statically_known.) - rust-lang/rust#154161 (On E0277 tweak help when single type impls traits) - rust-lang/rust#154218 (interpret/validity: remove unreachable error kind) - rust-lang/rust#154225 (diagnostics: avoid ICE in confusable_method_name for associated functions) - rust-lang/rust#154228 (Improve inline assembly error messages)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, building std for a custom Wasm target with an OS other than
unknownwill fail, becausesys/alloc/mod.rswill attempt to usesys/alloc/wasm.rs, the dlmalloc-based allocator used onwasm32-unknown-unknown. However, currently dlmalloc is only pulled in whentarget_os = "unknown".Instead, we should make
Cargo.tomlandalloc/mod.rsmatch: eitherwasm.rsinalloc/mod.rswherenot(target_os = "unknown"), ordlmallocfor all Wasm targets withtarget_family = "wasm32"that aren't covered by the upper branches ofalloc/mod.rs.This PR takes the latter approach, because it allows more code to compile without a custom allocator.