Skip to content

Commit 4ba1cf9

Browse files
committed
Auto merge of #146444 - heiher:fix-loong-jemalloc-page-size, r=Mark-Simulacrum
bootstrap: Build jemalloc for LoongArch with support for 16K pages By default, jemalloc is configured with a 4K page size. If the host’s page size is larger than this, it will crash at runtime. This patch raises the page size to 16K.
2 parents 5c11fb8 + 3597951 commit 4ba1cf9

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,14 +1383,17 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
13831383
}
13841384
}
13851385

1386-
// Build jemalloc on AArch64 with support for page sizes up to 64K
1387-
// See: https://github.com/rust-lang/rust/pull/135081
13881386
// See also the "JEMALLOC_SYS_WITH_LG_PAGE" setting in the tool build step.
1389-
if builder.config.jemalloc(target)
1390-
&& target.starts_with("aarch64")
1391-
&& env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none()
1392-
{
1393-
cargo.env("JEMALLOC_SYS_WITH_LG_PAGE", "16");
1387+
if builder.config.jemalloc(target) && env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none() {
1388+
// Build jemalloc on AArch64 with support for page sizes up to 64K
1389+
// See: https://github.com/rust-lang/rust/pull/135081
1390+
if target.starts_with("aarch64") {
1391+
cargo.env("JEMALLOC_SYS_WITH_LG_PAGE", "16");
1392+
}
1393+
// Build jemalloc on LoongArch with support for page sizes up to 16K
1394+
else if target.starts_with("loongarch") {
1395+
cargo.env("JEMALLOC_SYS_WITH_LG_PAGE", "14");
1396+
}
13941397
}
13951398
}
13961399

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,18 @@ pub fn prepare_tool_cargo(
228228
// own copy
229229
cargo.env("LZMA_API_STATIC", "1");
230230

231-
// Build jemalloc on AArch64 with support for page sizes up to 64K
232-
// See: https://github.com/rust-lang/rust/pull/135081
233231
// Note that `miri` always uses jemalloc. As such, there is no checking of the jemalloc build flag.
234232
// See also the "JEMALLOC_SYS_WITH_LG_PAGE" setting in the compile build step.
235-
if target.starts_with("aarch64") && env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none() {
236-
cargo.env("JEMALLOC_SYS_WITH_LG_PAGE", "16");
233+
if env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none() {
234+
// Build jemalloc on AArch64 with support for page sizes up to 64K
235+
// See: https://github.com/rust-lang/rust/pull/135081
236+
if target.starts_with("aarch64") {
237+
cargo.env("JEMALLOC_SYS_WITH_LG_PAGE", "16");
238+
}
239+
// Build jemalloc on LoongArch with support for page sizes up to 16K
240+
else if target.starts_with("loongarch") {
241+
cargo.env("JEMALLOC_SYS_WITH_LG_PAGE", "14");
242+
}
237243
}
238244

239245
// CFG_RELEASE is needed by rustfmt (and possibly other tools) which

0 commit comments

Comments
 (0)