Combination of `panic="abort"` and `-Zbuild-std` causes build failure
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I have tried this on ubuntu and alpine docker containers.
Steps:
-
Install dependencies
ubuntu:apt update && apt install curl clang
alpine:apk add curl clang musl-dev -
Try to build project:
curl --proto '=https' --tlsv1.3 -sSf https://sh.rustup.rs | sh
export PATH="$HOME/.cargo/bin:$PATH"
rustup override set nightly
rustup component add rust-src
cargo new test_build_std --vcs none
cd test_build_std
echo '[profile.release]' >> Cargo.toml
echo 'panic = "abort"' >> Cargo.toml
cargo build --release -Zbuild-std
I expected to see this happen: project successfully compiles
Instead, this happened: build failed with the following error
Alpine:
error[E0152]: duplicate lang item in crate `core`: `sized`
|
= note: the lang item is first defined in crate `core` (which `std` depends on)
= note: first definition in `core` loaded from /test_build_std/target/x86_64-unknown-linux-musl/release/deps/libcore-ea86b8bdb00db001.rlib, /test_build_std/target/x86_64-unknown-linux-musl/release/deps/libcore-ea86b8bdb00db001.rmeta
= note: second definition in `core` loaded from /root/.rustup/toolchains/nightly-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore-8c023576fd012662.rlib
For more information about this error, try `rustc --explain E0152`.
error: could not compile `test_build_std` (bin "test_build_std") due to 1 previous error
Ubuntu:
error[E0152]: duplicate lang item in crate `core`: `sized`
|
= note: the lang item is first defined in crate `core` (which `std` depends on)
= note: first definition in `core` loaded from /test_build_std/target/release/deps/libcore-521f42810889a0fe.rlib, /test_build_std/target/release/deps/libcore-521f42810889a0fe.rmeta
= note: second definition in `core` loaded from /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-62c8dfa7db58d93c.rlib
For more information about this error, try `rustc --explain E0152`.
error: could not compile `test_build_std` (bin "test_build_std") due to 1 previous error
Meta
rustc --version --verbose:
rustc 1.90.0-nightly (4b55fe199 2025-08-01)
binary: rustc
commit-hash: 4b55fe199cfe9c710555a5af7f2a49491ad38254
commit-date: 2025-08-01
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8
rustc 1.90.0-nightly (4b55fe199 2025-08-01)
binary: rustc
commit-hash: 4b55fe199cfe9c710555a5af7f2a49491ad38254
commit-date: 2025-08-01
host: x86_64-unknown-linux-musl
release: 1.90.0-nightly
LLVM version: 20.1.8
As I understand, the main problem is panic="abort", if I don't use that, build finishes successfully.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the minimal cargo new test_build_std project, nightly Rust, panic = "abort", and cargo build --release -Zbuild-std on Ubuntu or Alpine. Start from the duplicate core lang-item diagnostic and investigate the build-std handling of panic = "abort"; done means the minimal project builds successfully without duplicate core definitions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100