Skip to content

Regression: E0152 duplicate lang item 'sized' when using -Z build-std with Apple iOS targets #145629

@alycda

Description

@alycda

Code

I tried this code:

// Any Rust project with Cargo.toml
[package]
name = "test-lang-item"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["staticlib"]
cargo +nightly build --target aarch64-apple-ios-sim -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort

I expected to see this happen: The project should compile successfully for Apple iOS targets when using -Z build-std.

Instead, this happened: Compilation fails with duplicate lang item error during std_detect crate compilation:

error[E0152]: duplicate lang item in crate `core`: `sized`
  |
  = note: the lang item is first defined in crate `core` (which `std_detect` depends on)
  = note: first definition in `core` loaded from /target/aarch64-apple-ios-sim/release/deps/libcore-4c40bdd97baee939.rmeta
  = note: second definition in `core` loaded from /.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-ios-sim/lib/libcore-215222db00f59ba6.rlib

error: could not compile `std_detect` (lib) due to 1 previous error

Version it worked on

It most recently worked on: nightly-2025-08-15 (rustc 1.91.0-nightly (898aff7 2025-08-14))

Version with regression

rustc --version --verbose:

rustc 1.91.0-nightly (9eb4a2652 2025-08-18)
binary: rustc
commit-hash: 9eb4a2652031ed5ba97c29ef21c79db1645f7883
commit-date: 2025-08-18
host: aarch64-apple-darwin
release: 1.91.0-nightly
LLVM version: 21.1.0

Additional Information

  • Affected targets: aarch64-apple-ios, aarch64-apple-ios-sim, x86_64-apple-ios
  • Command variations: Issue occurs with various -Z build-std flag combinations
  • Impact: Blocking iOS development workflows and CI/CD pipelines
  • Environment: macOS with aarch64-apple-darwin host

The error suggests that there are conflicting definitions of the sized lang item between the locally built core crate (via -Z build-std) and the pre-compiled core crate from the toolchain.

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

Metadata

Metadata

Assignees

No one assigned

    Labels

    -Zbuild-stdUnstable Cargo option: Compile the standard library yourself.E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustcO-appleOperating system: Apple (macOS, iOS, tvOS, visionOS, watchOS)O-iosOperating system: iOSS-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions