-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-LTOArea: Link-time optimization (LTO)Area: Link-time optimization (LTO)C-bugCategory: This is a bug.Category: This is a bug.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
It seems that 7a01c7f introduced an issue with lto + WASM + global allocator
Details
rustc emits an unexpected _rdl
symbol for WASM (no_std) with lto=true
, which imports unavailable external functions:
...
(import "env" "_RNvCs3SlB0nJ74mU_7___rustc9___rdl_oom" (func $_RNvCs3SlB0nJ74mU_7___rustc9___rdl_oom (;0;) (type 0)))
...
This behavior is not observed with lto=false
OR the latest stable Rust (1.89)
Cargo.toml
[package]
name = "issue-wasm-lto"
edition = "2024"
[lib]
crate-type = ["cdylib"]
[profile.release]
lto = true
[dependencies]
dlmalloc = { version = "*", features = ["global"] }
lib.rs
#![no_std]
extern crate alloc;
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
core::arch::wasm32::unreachable();
}
#[global_allocator]
static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc;
#[unsafe(no_mangle)]
pub extern "C" fn test_sum(size: usize) -> usize {
// Allocate smth
alloc::vec::Vec::with_capacity(size).iter().sum()
}
build with
cargo +nightly build --target=wasm32-unknown-unknown --release
wasm-tools print target/wasm32-unknown-unknown/release/issue_wasm_lto.wasm > issue_wasm_lto.wat
Version it worked on
rustc 1.91.0-nightly (c8ca44c98 2025-08-10)
Version with regression
rustc 1.91.0-nightly (af00ff2ce 2025-09-04)
Metadata
Metadata
Assignees
Labels
A-LTOArea: Link-time optimization (LTO)Area: Link-time optimization (LTO)C-bugCategory: This is a bug.Category: This is a bug.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.