-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
-Zbuild-stdUnstable cargo option: -Zbuild-stdUnstable cargo option: -Zbuild-stdA-LTOArea: Link-time optimization (LTO)Area: Link-time optimization (LTO)A-crossArea: Cross compilationArea: Cross compilationC-bugCategory: This is a bug.Category: This is a bug.O-muslTarget: The musl libcTarget: The musl libcT-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.
Description
since nightly-2025-08-29
the combination of following factors leads to a compilation error:
- toolchain
x86_64-unknown-linux-gnu
- LTO enabled (both
thin
andfat
lead to failure) - cargo
-Zbuild-std=std
flag is used - target
x86_64-unknown-linux-musl
Code
I tried this code:
fn main() {}
cargo.toml
:
[package]
name = "repro"
version = "0.1.0"
edition = "2024"
[profile.dev]
lto = "fat"
I expected to see this happen:
$ cargo +nightly-2025-08-28-x86_64-unknown-linux-gnu build -Zbuild-std=std --target x86_64-unknown-linux-musl
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s
Instead, this happened:
$ cargo +nightly-2025-08-29-x86_64-unknown-linux-gnu build -Zbuild-std=std --target x86_64-unknown-linux-musl
Compiling repro v0.1.0 ($DIR)
error: linking with `cc` failed: exit status: 1
|
= note: "cc" "-m64" "<sysroot>/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/rcrt1.o" "<sysroot>/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crti.o" "<sysroot>/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtbeginS.o" "<68 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "-lunwind" "-lc" "$DIR/target/x86_64-unknown-linux-musl/debug/deps/libcompiler_builtins-c7f4fcb50b8f358d.rlib" "-L" "/tmp/rustckKscQc/raw-dylibs" "-Wl,-Bdynamic" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-nostartfiles" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-musl/lib" "-o" "$DIR/target/x86_64-unknown-linux-musl/debug/deps/repro-0da546c4af9fdcc4" "-Wl,--gc-sections" "-static-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-fuse-ld=lld" "<sysroot>/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtendS.o" "<sysroot>/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtn.o"
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: ld.lld: error: $DIR/target/x86_64-unknown-linux-musl/debug/deps/libcompiler_builtins-c7f4fcb50b8f358d.rlib(compiler_builtins-c7f4fcb50b8f358d.compiler_builtins.d1b674884d9f97b8-cgu.0.rcgu.o): Invalid record
collect2: error: ld returned 1 exit status
error: could not compile `repro` (bin "repro") due to 1 previous error
Version it worked on
It most recently worked on: nightly-2025-08-28
Version with regression
rustc --version --verbose
:
$ cargo +nightly-2025-08-29-x86_64-unknown-linux-gnu rustc -- --version --verbose
Compiling repro v0.1.0 ($DIR)
rustc 1.91.0-nightly (f2824da98 2025-08-28)
binary: rustc
commit-hash: f2824da98d44c4a4e17bf39eb45103c8fc249117
commit-date: 2025-08-28
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0
I'm not sure whether this should rather be reported in the repository of cargo
. If that's so I can create the issue there instead.
Metadata
Metadata
Assignees
Labels
-Zbuild-stdUnstable cargo option: -Zbuild-stdUnstable cargo option: -Zbuild-stdA-LTOArea: Link-time optimization (LTO)Area: Link-time optimization (LTO)A-crossArea: Cross compilationArea: Cross compilationC-bugCategory: This is a bug.Category: This is a bug.O-muslTarget: The musl libcTarget: The musl libcT-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.