Skip to content

bootstrap: Fix jemalloc 64K page support for aarch64 tools - #145353

Merged
bors merged 1 commit into
rust-lang:masterfrom
CathalMullan:jemalloc-tools
Aug 15, 2025
Merged

bootstrap: Fix jemalloc 64K page support for aarch64 tools#145353
bors merged 1 commit into
rust-lang:masterfrom
CathalMullan:jemalloc-tools

Conversation

@CathalMullan

@CathalMullanCathalMullan commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

Resolves#133748

The prior page size fix only targeted the compile build step, not the tools step: #135081

Also note that since miri always uses jemalloc, I didn't copy the builder.config.jemalloc(target) check to the tools section.

Tested by running strings on the compiled miri binary to see the LG_PAGE value.

Before:

> strings miri | grep '^LG_PAGE'
LG_PAGE 14

After:

> strings miri | grep '^LG_PAGE'
LG_PAGE 16

May also need a separate fix for the standalone miri repository: rust-lang/miri#4514 (likely a change needed in miri-script?)

@rustbot

Copy link
Copy Markdown
Collaborator

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Aug 13, 2025
@Kobzol

Copy link
Copy Markdown
Member

r? @Kobzol

That makes sense, thank you! Let's try a few ARM jobs:

@bors try jobs=aarch64-gnu,dist-aarch64-linux

@rust-bors

This comment has been minimized.

rust-borsBot added a commit that referenced this pull request Aug 13, 2025
bootstrap: Fix jemalloc 64K page support for aarch64 tools
try-job: aarch64-gnu
try-job: dist-aarch64-linux
@rust-bors

rust-borsBot commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 44782a5 (44782a51d481db9ee759237c7cdb83ed16fae3da, parent: 1c9952f4dd6e0947ee91f07130c03813a088a894)

@Kobzol

Copy link
Copy Markdown
Member

Thanks!

@bors r+

@bors

bors commented Aug 13, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit ebcbcc8 has been approved by Kobzol

It is now in the queue for this repository.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 13, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 14, 2025
bootstrap: Fix jemalloc 64K page support for aarch64 tools
Resolvesrust-lang#133748
The prior page size fix only targeted the compile build step, not the tools step: rust-lang#135081
Also note that since `miri` always uses jemalloc, I didn't copy the `builder.config.jemalloc(target)` check to the tools section.
Tested by running `strings` on the compiled `miri` binary to see the LG_PAGE value.
Before:
```
> strings miri | grep '^LG_PAGE'
LG_PAGE 14
```
After:
```
> strings miri | grep '^LG_PAGE'
LG_PAGE 16
```
May also need a separate fix for the standalone miri repository: rust-lang/miri#4514 (likely a change needed in miri-script?)
@ZalatharZalathar mentioned this pull request Aug 14, 2025
bors added a commit that referenced this pull request Aug 14, 2025
Rollup of 13 pull requests
Successful merges:
- #122661 (Change the desugaring of `assert!` for better error output)
- #142372 (Improve `--remap-path-prefix` documentation)
- #143075 (compiler: Allow `extern "interrupt" fn() -> !`)
- #145005 (strip prefix of temporary file names when it exceeds filesystem name length limit)
- #145065 (resolve: Introduce `RibKind::Block`)
- #145120 (llvm: Accept new LLVM lifetime format)
- #145189 (Weekly `cargo update`)
- #145261 (Improve tracing in bootstrap)
- #145266 (Reduce some queries around associated items)
- #145299 (doc test: fix mpsc.rs try_send doc test)
- #145331 (Make std use the edition 2024 prelude)
- #145353 (bootstrap: Fix jemalloc 64K page support for aarch64 tools)
- #145361 (Suppress wrapper suggestion when expected and actual ty are the same adt and the variant is unresolved)
Failed merges:
- #145324 (Rename and document `ONLY_HOSTS` in bootstrap)
- #145372 (resolve: Miscellaneous cleanups)
r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Aug 14, 2025
Rollup of 13 pull requests
Successful merges:
- #122661 (Change the desugaring of `assert!` for better error output)
- #142372 (Improve `--remap-path-prefix` documentation)
- #143075 (compiler: Allow `extern "interrupt" fn() -> !`)
- #145005 (strip prefix of temporary file names when it exceeds filesystem name length limit)
- #145065 (resolve: Introduce `RibKind::Block`)
- #145120 (llvm: Accept new LLVM lifetime format)
- #145189 (Weekly `cargo update`)
- #145261 (Improve tracing in bootstrap)
- #145266 (Reduce some queries around associated items)
- #145299 (doc test: fix mpsc.rs try_send doc test)
- #145331 (Make std use the edition 2024 prelude)
- #145353 (bootstrap: Fix jemalloc 64K page support for aarch64 tools)
- #145361 (Suppress wrapper suggestion when expected and actual ty are the same adt and the variant is unresolved)
Failed merges:
- #145324 (Rename and document `ONLY_HOSTS` in bootstrap)
- #145372 (resolve: Miscellaneous cleanups)
r? `@ghost`
`@rustbot` modify labels: rollup
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Aug 14, 2025
bootstrap: Fix jemalloc 64K page support for aarch64 tools
Resolvesrust-lang#133748
The prior page size fix only targeted the compile build step, not the tools step: rust-lang#135081
Also note that since `miri` always uses jemalloc, I didn't copy the `builder.config.jemalloc(target)` check to the tools section.
Tested by running `strings` on the compiled `miri` binary to see the LG_PAGE value.
Before:
```
> strings miri | grep '^LG_PAGE'
LG_PAGE 14
```
After:
```
> strings miri | grep '^LG_PAGE'
LG_PAGE 16
```
May also need a separate fix for the standalone miri repository: rust-lang/miri#4514 (likely a change needed in miri-script?)
bors added a commit that referenced this pull request Aug 14, 2025
Rollup of 9 pull requests
Successful merges:
- #118087 (Add Ref/RefMut try_map method)
- #140794 (Add information about group a lint belongs to)
- #144947 (Fix description of unsigned `checked_exact_div`)
- #145005 (strip prefix of temporary file names when it exceeds filesystem name length limit)
- #145233 (cfg_select: Support unbraced expressions)
- #145243 (take attr style into account in diagnostics)
- #145353 (bootstrap: Fix jemalloc 64K page support for aarch64 tools)
- #145379 (bootstrap: Support passing `--timings` to cargo)
- #145389 ([rustdoc] Revert "rustdoc search: prefer stable items in search results")
Failed merges:
- #144983 (Rehome 37 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`)
- #145065 (resolve: Introduce `RibKind::Block`)
r? `@ghost`
`@rustbot` modify labels: rollup
Kobzol added a commit to Kobzol/rust that referenced this pull request Aug 14, 2025
bootstrap: Fix jemalloc 64K page support for aarch64 tools
Resolvesrust-lang#133748
The prior page size fix only targeted the compile build step, not the tools step: rust-lang#135081
Also note that since `miri` always uses jemalloc, I didn't copy the `builder.config.jemalloc(target)` check to the tools section.
Tested by running `strings` on the compiled `miri` binary to see the LG_PAGE value.
Before:
```
> strings miri | grep '^LG_PAGE'
LG_PAGE 14
```
After:
```
> strings miri | grep '^LG_PAGE'
LG_PAGE 16
```
May also need a separate fix for the standalone miri repository: rust-lang/miri#4514 (likely a change needed in miri-script?)
This was referenced Aug 14, 2025
bors added a commit that referenced this pull request Aug 14, 2025
Rollup of 11 pull requests
Successful merges:
- #137872 (Include whitespace in "remove |" suggestion and make it hidden)
- #144631 (Fix test intrinsic-raw_eq-const-bad for big-endian)
- #145233 (cfg_select: Support unbraced expressions)
- #145261 (Improve tracing in bootstrap)
- #145324 (Rename and document `ONLY_HOSTS` in bootstrap)
- #145353 (bootstrap: Fix jemalloc 64K page support for aarch64 tools)
- #145379 (bootstrap: Support passing `--timings` to cargo)
- #145397 (Rust documentation, use `rustc-dev-guide` :3)
- #145398 (Use `default_field_values` in `Resolver`)
- #145401 (cleanup: Remove useless `[T].iter().last()`)
- #145403 (Adjust error message grammar to be less awkward)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 55f2234 into rust-lang:masterAug 15, 2025
11 checks passed
@rustbotrustbot added this to the 1.91.0 milestone Aug 15, 2025
rust-timer added a commit that referenced this pull request Aug 15, 2025
Rollup merge of #145353 - CathalMullan:jemalloc-tools, r=Kobzol
bootstrap: Fix jemalloc 64K page support for aarch64 tools
Resolves#133748
The prior page size fix only targeted the compile build step, not the tools step: #135081
Also note that since `miri` always uses jemalloc, I didn't copy the `builder.config.jemalloc(target)` check to the tools section.
Tested by running `strings` on the compiled `miri` binary to see the LG_PAGE value.
Before:
```
> strings miri | grep '^LG_PAGE'
LG_PAGE 14
```
After:
```
> strings miri | grep '^LG_PAGE'
LG_PAGE 16
```
May also need a separate fix for the standalone miri repository: rust-lang/miri#4514 (likely a change needed in miri-script?)
github-actionsBot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Aug 18, 2025
Rollup of 11 pull requests
Successful merges:
- rust-lang/rust#137872 (Include whitespace in "remove |" suggestion and make it hidden)
- rust-lang/rust#144631 (Fix test intrinsic-raw_eq-const-bad for big-endian)
- rust-lang/rust#145233 (cfg_select: Support unbraced expressions)
- rust-lang/rust#145261 (Improve tracing in bootstrap)
- rust-lang/rust#145324 (Rename and document `ONLY_HOSTS` in bootstrap)
- rust-lang/rust#145353 (bootstrap: Fix jemalloc 64K page support for aarch64 tools)
- rust-lang/rust#145379 (bootstrap: Support passing `--timings` to cargo)
- rust-lang/rust#145397 (Rust documentation, use `rustc-dev-guide` :3)
- rust-lang/rust#145398 (Use `default_field_values` in `Resolver`)
- rust-lang/rust#145401 (cleanup: Remove useless `[T].iter().last()`)
- rust-lang/rust#145403 (Adjust error message grammar to be less awkward)
r? `@ghost`
`@rustbot` modify labels: rollup
AgentEnder pushed a commit to nrwl/nx that referenced this pull request Apr 21, 2026
…page kernels (#35356)
## Current Behavior
On aarch64 Linux kernels with page sizes larger than 4 KiB — 16 KiB on
Asahi Linux / Apple Silicon, 64 KiB on some Ampere/Fedora server configs
— every Nx command (including `nx --version`) aborts immediately:
```
<jemalloc>: Unsupported system page size
<jemalloc>: arena_new: allocation failed
memory allocation of 576 bytes failed
Aborted (core dumped)
```
The cause: jemalloc is compiled with `--with-lg-page=12` (4 KiB
allocator page) by default, and refuses to operate when the system page
size exceeds the compiled-in value.
## Expected Behavior
Nx native binaries run correctly on every shipping aarch64 Linux kernel
(4 KiB, 16 KiB, 64 KiB pages), without losing the performance benefits
of jemalloc on the common 4 KiB-page configurations (Graviton, cloud
ARM, Raspberry Pi OS, Debian/Ubuntu ARM).
The fix: build `@nx/nx-linux-arm64-gnu` and `@nx/nx-linux-arm64-musl`
with `JEMALLOC_SYS_WITH_LG_PAGE=16` (64 KiB allocator page). jemalloc's
documented contract is `allocator_page_size ≥ system_page_size`, so a
binary built this way runs on any aarch64 Linux kernel with page size ≤
64 KiB — which covers all known configurations.
## Prior art
The same `JEMALLOC_SYS_WITH_LG_PAGE=16` approach is used by:
- **rustc** —
[rust-lang/rust#145353](rust-lang/rust#145353):
`cargo.env("JEMALLOC_SYS_WITH_LG_PAGE", "16")` for aarch64 targets in
`src/bootstrap/src/core/build_steps/tool.rs`
- **swc** —
[swc-project/swc#6541](swc-project/swc#6541):
`export JEMALLOC_SYS_WITH_LG_PAGE=16` in the publish workflow for both
aarch64 gnu and musl rows
- **fd** — [sharkdp/fd#1547](sharkdp/fd#1547)
and follow-up [#1549](sharkdp/fd#1549) moving
the env var into `Cross.toml` via `passthrough`
- **Homebrew** —
[`Library/Homebrew/extend/os/linux/extend/ENV/super.rb`](https://github.com/Homebrew/brew/blob/master/Library/Homebrew/extend/os/linux/extend/ENV/super.rb):
`self["JEMALLOC_SYS_WITH_LG_PAGE"] = "16"` (applied globally to Homebrew
Linux aarch64 builds)
- **Arch Linux ARM** —
[`extra/fd/PKGBUILD`](https://github.com/archlinuxarm/PKGBUILDs/blob/master/extra/fd/PKGBUILD):
`[[ $CARCH == "aarch64" ]] && export JEMALLOC_SYS_WITH_LG_PAGE=16`
## Related Issue(s)
Fixes#35345
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

miri is incorrectly built with jemalloc on some targets

5 participants

@CathalMullan@rustbot@Kobzol@bors@Mark-Simulacrum