Skip to content

[-Zbuild-std] Duplicate lang item with panic=abort #15058

@hoodmane

Description

@hoodmane

Problem

panic=abort doesn't work with -Zbuild-std.
xref related issues:
rust-lang/wg-cargo-std-aware#29
#7359

This is probably the same issue as #7359. I am opening this as well because the reproduction is simpler. I get the same error when I try to use https://github.com/RalfJung/rustc-build-sysroot to build my own sysroot.

Steps

Presumably this problem has been around for a while but for definiteness I picked today's nightly.

Make a folder with the following two files:

Cargo.toml

[package]
name = "test"
edition = "2024"

[profile.dev]
panic = "abort"

[[bin]]
name = "test"
path = "main.rs"

main.rs

pub fn main() { }

Bash

  1. rustup install nightly-2025-01-13
  2. cargo build -Zbuild-std

Result

   Compiling tmp v0.0.0 (/home/rchatham/Documents/programming/rust-wasm-eh-test-2)
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 /home/rchatham/Documents/programming/rust-wasm-eh-test-2/target/wasm32-unknown-emscripten/debug/deps/libcore-05cdacbb5559ef58.rlib, /home/rchatham/Documents/programming/rust-wasm-eh-test-2/target/wasm32-unknown-emscripten/debug/deps/libcore-05cdacbb5559ef58.rmeta
  = note: second definition in `core` loaded from /home/rchatham/.rustup/toolchains/nightly-2025-01-13-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libcore-9c3bca22b80bc54a.rlib

For more information about this error, try `rustc --explain E0152`.
error: could not compile `test` (bin "test") due to 1 previous error

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.86.0-nightly (088d49608 2025-01-10)
release: 1.86.0-nightly
commit-hash: 088d496082726091024f1689c124a0c3dccbd775
commit-date: 2025-01-10
host: x86_64-unknown-linux-gnu
libgit2: 1.9.0 (sys:0.20.0 vendored)
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Ubuntu 22.4.0 (jammy) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions