Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build std with panic = "abort" errors with a bunch of duplicated lang items #115963

Open
xTachyon opened this issue Sep 19, 2023 · 2 comments
Open
Labels
-Zbuild-std Unstable Cargo option: Compile the standard library yourself. A-crates Area: Crates and their interactions (like crate loading) A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@xTachyon
Copy link
Contributor

xTachyon commented Sep 19, 2023

Code

[profile.release]
panic = "abort"
rustup run nightly-2023-09-17 cargo rustc -p dune --profile release -Z build-std=std,core --target x86_64-pc-windows-msvc

The nightly version is not important, it's only what I was testing on.

Current output

A bunch of these:

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 \\?\D:\repos\dune\target\x86_64-pc-windows-msvc\release\deps\libcore-8e933d06c178c4de.rlib, \\?\D:\repos\dune\target\x86_64-pc-windows-msvc\release\deps\libcore-8e933d06c178c4de.rmeta
  = note: second definition in `core` loaded from \\?\C:\Users\tachyon\.rustup\toolchains\nightly-2023-08-17-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcore-b86a9ba077d96bbb.rlib

Desired output

A nice message that said panic_abort must be included in build-std if compiled with panic = "abort".

Rationale and extra context

From @Nilstrieb:
rustc can't find a panic_abort in your self-built standard library, so it falls back to loading panic_abort from the sysroot. But that sysroot panic_abort then also brings in the rest of the sysroot, including core, so now you have two cores, one from your target dir and one from your sysroot. This is bad.

Other cases

No response

Anything else?

No response

@xTachyon xTachyon added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 19, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 19, 2023
@Noratrieb
Copy link
Member

Probably makes sense to have a specialized error message when loading core twice.

@Noratrieb Noratrieb added -Zbuild-std Unstable Cargo option: Compile the standard library yourself. A-crates Area: Crates and their interactions (like crate loading) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 19, 2023
@klensy
Copy link
Contributor

klensy commented Sep 20, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zbuild-std Unstable Cargo option: Compile the standard library yourself. A-crates Area: Crates and their interactions (like crate loading) A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants