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

Cargo links libcore twice when compiling with -Zbuild-std and panic=abort #14131

Closed
grayratrudeus2 opened this issue Jun 24, 2024 · 1 comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage. Z-build-std Nightly: build-std

Comments

@grayratrudeus2
Copy link

grayratrudeus2 commented Jun 24, 2024

Problem

its seems like libcore is being linked twice one from built std and one from prebuilt one Error

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 <project-dir>\target\x86_64-pc-windows-msvc\release\deps\libcore-9934970537b87ae5.rlib, <project-dir>\target\x86_64-pc-windows-msvc\release\deps\libcore-9934970537b87ae5.rmeta
  = note: second definition in `core` loaded from <rustup-dir>\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcore-0a7d9524c210bd3d.rlib

For more information about this error, try `rustc --explain E0152`

Steps

  1. create a binary project using cargo new
  2. add panic="abort" in release profile
  3. add rust flag "-Crelocation-model=pic"
  4. compile using "cargo b -Zbuild-std --target x86_64-pc-windows-msvc --release"

Possible Solution(s)

No response

Notes

I'm trying to create PIE using rust yet no success

Version

cargo 1.81.0-nightly (bc89bffa5 2024-06-22)
release: 1.81.0-nightly
commit-hash: bc89bffa5987d4af8f71011c7557119b39e44a65
commit-date: 2024-06-22
host: x86_64-pc-windows-msvc
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.6.0-DEV (sys:0.4.72+curl-8.6.0 vendored ssl:Schannel)
os: Windows 10.0.20348 [64-bit]
@grayratrudeus2 grayratrudeus2 added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Jun 24, 2024
@ehuss
Copy link
Contributor

ehuss commented Jun 24, 2024

Thanks for the report! I'm going to close as a duplicate of rust-lang/wg-cargo-std-aware#29. Support for abort hasn't ever really worked very well. In the meantime, I think you can do -Zbuild-std=std,panic_abort as a workaround.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2024
@weihanglo weihanglo added the Z-build-std Nightly: build-std label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage. Z-build-std Nightly: build-std
Projects
None yet
Development

No branches or pull requests

3 participants