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

[-Zbuild-std] Duplicate lang item error for no-harness test and profile.dev.panic = abort #7359

Open
phil-opp opened this issue Sep 13, 2019 · 9 comments
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage. Z-build-std Nightly: build-std

Comments

@phil-opp
Copy link
Contributor

Combining a no-harness test with a panic=abort key in the Cargo.toml leads to duplicate lang item errors if compiled with cargo test -Zbuild-std=core.

Steps to Reproduce

  1. Create a new cargo project with the following contents:

    Cargo.toml:

    [package]
    name = "playground"
    version = "0.1.0"
    authors = ["Philipp Oppermann <dev@phil-opp.com>"]
    edition = "2018"
    
    [lib]
    harness = false
    
    [dependencies]
    
    [profile.dev]
    panic = "abort"     # it works if this line is removed

    src/lib.rs:

    #![no_std]
    #![cfg_attr(test, no_main)]
    
    #[cfg(test)]
    #[panic_handler]
    fn panic(_info: &core::panic::PanicInfo) -> ! {
        loop {}
    }

    target.json:

    {
        "llvm-target": "x86_64-unknown-none",
        "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
        "arch": "x86_64",
        "target-endian": "little",
        "target-pointer-width": "64",
        "target-c-int-width": "32",
        "os": "none",
        "executables": true,
        "linker-flavor": "ld.lld",
        "linker": "rust-lld",
        "panic-strategy": "abort",
        "disable-redzone": true,
        "features": "-mmx,-sse,+soft-float"
      }
  2. Run cargo test --target target.json -Z build-std=core --no-run

    The following error occurs:

    cargo test --target target.json -Z build-std=core
     Compiling playground v0.1.0 (…)
     error: duplicate lang item in crate `core`: `bool`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `char`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `str`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `slice`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `slice_u8`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `const_ptr`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `mut_ptr`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `i8`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `i16`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `i32`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `i64`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `i128`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `isize`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `u8`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `u16`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `u32`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `u64`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `u128`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `usize`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `f32`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `f64`.
     |
     error: duplicate lang item in crate `core`: `bool`.
     = note: first defined in crate `core`.
     |
    
     error: duplicate lang item in crate `core`: `sized`.
     = note: first defined in crate `core`.
    
     |
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `char`.
    
     |
     error: duplicate lang item in crate `core`: `unsize`.
     = note: first defined in crate `core`.
     |
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `str`.
     |
     error: duplicate lang item in crate `core`: `copy`.
     |
     = note: first defined in crate `core`.
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `slice`.
     |
     error: duplicate lang item in crate `core`: `clone`.
     = note: first defined in crate `core`.
     |
    
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `slice_u8`.
    
     |
     error: duplicate lang item in crate `core`: `sync`.
     = note: first defined in crate `core`.
     |
    
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `const_ptr`.
    
     |
     error: duplicate lang item in crate `core`: `freeze`.
     = note: first defined in crate `core`.
     |
    
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `mut_ptr`.
    
     |
     error: duplicate lang item in crate `core`: `drop`.
     = note: first defined in crate `core`.
     |
    
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `i8`.
    
     |
     error: duplicate lang item in crate `core`: `coerce_unsized`.
     = note: first defined in crate `core`.
    
     |
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `i16`.
    
     |
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `dispatch_from_dyn`.
    
     |
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `i32`.
    
     |
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `add`.
    
     |
     error: duplicate lang item in crate `core`: `i64`.
     = note: first defined in crate `core`.
    
     |
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `sub`.
    
     |
     error: duplicate lang item in crate `core`: `i128`.
     = note: first defined in crate `core`.
    
     |
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `mul`.
    
     |
     error: duplicate lang item in crate `core`: `isize`.
     = note: first defined in crate `core`.
     |
    
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `div`.
    
     |
     error: duplicate lang item in crate `core`: `u8`.
     = note: first defined in crate `core`.
     |
    
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `rem`.
    
     |
     error: duplicate lang item in crate `core`: `u16`.
     = note: first defined in crate `core`.
     |
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `neg`.
     |
     error: duplicate lang item in crate `core`: `u32`.
     = note: first defined in crate `core`.
     |
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `not`.
     |
     error: duplicate lang item in crate `core`: `u64`.
     |
     = note: first defined in crate `core`.
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `bitxor`.
     |
     error: duplicate lang item in crate `core`: `u128`.
     |
     = note: first defined in crate `core`.
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `bitand`.
     |
     error: duplicate lang item in crate `core`: `usize`.
     |
     = note: first defined in crate `core`.
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `bitor`.
     error: duplicate lang item in crate `core`: `f32`.
     |
     |
     = note: first defined in crate `core`.
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `shl`.
     error: duplicate lang item in crate `core`: `f64`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `shr`.
     error: duplicate lang item in crate `core`: `sized`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `add_assign`.
     error: duplicate lang item in crate `core`: `unsize`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `sub_assign`.
     error: duplicate lang item in crate `core`: `copy`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `mul_assign`.
     error: duplicate lang item in crate `core`: `clone`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `div_assign`.
     error: duplicate lang item in crate `core`: `sync`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `rem_assign`.
     error: duplicate lang item in crate `core`: `freeze`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `bitxor_assign`.
     error: duplicate lang item in crate `core`: `drop`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `bitand_assign`.
     error: duplicate lang item in crate `core`: `coerce_unsized`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `bitor_assign`.
     error: duplicate lang item in crate `core`: `dispatch_from_dyn`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `shl_assign`.
     error: duplicate lang item in crate `core`: `add`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `sub`.
     error: duplicate lang item in crate `core`: `shr_assign`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `index`.
     error: duplicate lang item in crate `core`: `mul`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `index_mut`.
     error: duplicate lang item in crate `core`: `div`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `rem`.
     error: duplicate lang item in crate `core`: `unsafe_cell`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `neg`.
     |
     error: duplicate lang item in crate `core`: `va_list`.
     = note: first defined in crate `core`.
    
     |
     error: duplicate lang item in crate `core`: `not`.
     = note: first defined in crate `core`.
     |
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `bitxor`.
     |
     error: duplicate lang item in crate `core`: `deref`.
     = note: first defined in crate `core`.
     |
    
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `bitand`.
    
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `deref_mut`.
     error: duplicate lang item in crate `core`: `bitor`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `receiver`.
     error: duplicate lang item in crate `core`: `shl`.
     |
     |
     = note: first defined in crate `core`.
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `fn`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `fn_mut`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `fn_once`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `future_trait`.
     error: duplicate lang item in crate `core`: `shr`.
     |
     = note: first defined in crate `core`.
    
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `add_assign`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `sub_assign`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `mul_assign`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `div_assign`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `rem_assign`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `bitxor_assign`.
     error: duplicate lang item in crate `core`: `generator_state`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `bitand_assign`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `bitor_assign`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `shl_assign`.
     |
     = note: first defined in crate `core`.
    
     |
     error: duplicate lang item in crate `core`: `shr_assign`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `index`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `index_mut`.
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `unsafe_cell`.
     |
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `generator`.
     error: duplicate lang item in crate `core`: `va_list`.
     |
     |
     = note: first defined in crate `core`.
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `deref`.
     |
     error: duplicate lang item in crate `core`: `unpin`.
     = note: first defined in crate `core`.
    
     |
     error: duplicate lang item in crate `core`: `deref_mut`.
     = note: first defined in crate `core`.
     |
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `receiver`.
     error: duplicate lang item in crate `core`: `pin`.
     |
     = note: first defined in crate `core`.
     |
    
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `fn`.
     |
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `eq`.
     error: duplicate lang item in crate `core`: `fn_mut`.
     |
     |
     = note: first defined in crate `core`.
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `fn_once`.
     |
     error: duplicate lang item in crate `core`: `partial_ord`.
     = note: first defined in crate `core`.
    
     |
     error: duplicate lang item in crate `core`: `future_trait`.
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `generator_state`.
     |
     error: duplicate lang item in crate `core`: `ord`.
     |
     = note: first defined in crate `core`.
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `generator`.
     |
     error: duplicate lang item in crate `core`: `panic`.
     = note: first defined in crate `core`.
     |
    
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `unpin`.
    
     |
     error: duplicate lang item in crate `core`: `panic_bounds_check`.
     = note: first defined in crate `core`.
     |
    
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `pin`.
    
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `eq`.
     error: duplicate lang item in crate `core`: `panic_info`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `partial_ord`.
     error: duplicate lang item in crate `core`: `drop_in_place`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `ord`.
     error: duplicate lang item in crate `core`: `alloc_layout`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `panic`.
     error: duplicate lang item in crate `core`: `phantom_data`.
     |
     |
     = note: first defined in crate `core`.
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `panic_bounds_check`.
     error: duplicate lang item in crate `core`: `manually_drop`.
     |
     |
     = note: first defined in crate `core`.
     = note: first defined in crate `core`.
    
    
     error: duplicate lang item in crate `core`: `panic_info`.
     error: duplicate lang item in crate `core`: `maybe_uninit`.
     |
     |
     = note: first defined in crate `core`.
    
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `drop_in_place`.
     |
     error: duplicate lang item in crate `core`: `align_offset`.
     = note: first defined in crate `core`.
     |
    
     = note: first defined in crate `core`.
     error: duplicate lang item in crate `core`: `alloc_layout`.
    
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `phantom_data`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `manually_drop`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `maybe_uninit`.
     |
     = note: first defined in crate `core`.
    
     error: duplicate lang item in crate `core`: `align_offset`.
     |
     = note: first defined in crate `core`.
    
     error: aborting due to 79 previous errors
    
     error: argument should be `&PanicInfo`
     --> src/lib.rs:6:17
     |
     6 | fn panic(_info: &core::panic::PanicInfo) -> ! {
     |                 ^^^^^^^^^^^^^^^^^^^^^^^
    
     error: Could not compile `playground`.
     warning: build failed, waiting for other jobs to finish...
     error: aborting due to 80 previous errors
    
     error: Could not compile `playground`.
    
     To learn more, run the command again with --verbose.
    
  3. Remove the panic=abort line from the Cargo.toml

  4. Rerun the command from step 2 (cargo test --target target.json -Z build-std=core --no-run). It works now.

My Guess

My guess is that the core library is somehow compiled twice when the panic=abort line is specified.

Version

cargo 1.39.0-nightly (fe0e5a4 2019-09-04)

@phil-opp phil-opp added the C-bug Category: bug label Sep 13, 2019
@alexcrichton
Copy link
Member

I think this is covered by rust-lang/wg-cargo-std-aware#29 for now where panic=abort isn't super well supported. Especially with cargo test things get funky because Cargo tries to compile some parts of the crate graph with panic=unwind instead of panic=abort. Overall in general the panic story isn't sorted out yet, so having more data points is good, thanks!

@phil-opp
Copy link
Contributor Author

I don't think that any crates are compiled with unwinding in this example because the target itself specfies "panic-strategy": "abort". So the profile.dev.panic key is not needed at all for this example.

As another data point, I was able to successfully run cargo test -Zbuild-std=core,alloc for https://github.com/phil-opp/blog_os after deleting the superfluous profile.dev.panic key. So specifying panic=abort in the target JSON file seems to work without problems.

Feel free to close this in favor of the working group issue if you like.

@alexcrichton
Copy link
Member

Oh true yeah, but Cargo compiles one with -Cpanic=unwind (which I guess is an ignored setting) and again with -Cpanic=abort so I think that's where the two lang items are coming from. In any case I'd like to keep this issue open as a concrete test case we'll want to fix when accounting for panic support with -Zbuild-std, there may be something fishy here that I'm not understanding fully yet.

@alexcrichton alexcrichton reopened this Sep 14, 2019
@ehuss ehuss added the Z-build-std Nightly: build-std label Sep 21, 2019
@RReverser
Copy link
Contributor

RReverser commented Oct 17, 2019

I'm seeing same error even without panic=abort when trying to build raytrace-parallel example from here https://github.com/rustwasm/wasm-bindgen/tree/master/examples/raytrace-parallel, but on Windows instead of Linux.

I'm not sure what are the platform differences, but so far none of custom build-std=... combinations seem to help :(

The closest I got was passing -Zbuild-std=...,alloc on the command line, but then Rust complains with

error: macro-expanded `extern crate` items cannot shadow names passed with `--extern`
  --> C:\Users\rreverser\.cargo\registry\src\git.luolix.top-1ecc6299db9ec823\crossbeam-epoch-0.7.2\src\lib.rs:72:9
   |
72 |         extern crate std as alloc;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^

because some crates like Crossbeam use cfg_if to alias std as alloc like

cfg_if! {
    if #[cfg(feature = "alloc")] {
        extern crate alloc;
    } else if #[cfg(feature = "std")] {
        extern crate std as alloc;
    }
}

and I'm not sure how to disable that check either.

@alexcrichton
Copy link
Member

@RReverser that's a too-old version of Cargo, that issue should be fixed in nightlies.

@stevefan1999-personal
Copy link

I'm seeing same error even without panic=abort when trying to build raytrace-parallel example from here https://github.com/rustwasm/wasm-bindgen/tree/master/examples/raytrace-parallel, but on Windows instead of Linux.

I'm not sure what are the platform differences, but so far none of custom build-std=... combinations seem to help :(

The closest I got was passing -Zbuild-std=...,alloc on the command line, but then Rust complains with

error: macro-expanded `extern crate` items cannot shadow names passed with `--extern`
  --> C:\Users\rreverser\.cargo\registry\src\git.luolix.top-1ecc6299db9ec823\crossbeam-epoch-0.7.2\src\lib.rs:72:9
   |
72 |         extern crate std as alloc;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^

because some crates like Crossbeam use cfg_if to alias std as alloc like

cfg_if! {
    if #[cfg(feature = "alloc")] {
        extern crate alloc;
    } else if #[cfg(feature = "std")] {
        extern crate std as alloc;
    }
}

and I'm not sure how to disable that check either.

This is exactly the problem you described for what I encountered, and still not working using the latest version of nightly Rust as of the date of this comment.

@joshtriplett
Copy link
Member

I can reproduce this with latest nightly, with just cargo new foo, adding a [profile.release] section that sets panic = "abort", and building with cargo build -Zbuild-std --release --target x86_64-unknown-linux-gnu.

phil-opp added a commit to phil-opp/blog_os that referenced this issue Jul 21, 2020
sinjs added a commit to sinjs/kron that referenced this issue Jul 16, 2021
SlyMarbo added a commit to ProjectSerenity/firefly that referenced this issue Nov 8, 2021
The various changes over the last year or so broke testing with
cargo xtest, but we can now use cargo test instead.

Note that we had to remove the (admittedly redundant) declarations
of `panic = "abort"` in both `dev` and `release` profiles in
Cargo.toml, thanks to rust-lang/cargo#7359.

The only thing left is the repeated deprecation warning from
bootloader, tracked in rust-osdev/bootloader#107,
which needs to be reopend at time of writing.
SlyMarbo added a commit to ProjectSerenity/firefly that referenced this issue Nov 8, 2021
The various changes over the last year or so broke testing with
cargo xtest, but we can now use cargo test instead.

Note that we had to remove the (admittedly redundant) declarations
of `panic = "abort"` in both `dev` and `release` profiles in
Cargo.toml, thanks to rust-lang/cargo#7359.

The only thing left is the repeated deprecation warning from
bootloader, tracked in rust-osdev/bootloader#107,
which needs to be reopend at time of writing.
jmcph4 added a commit to jmcph4/rust-os-tutorial that referenced this issue Jan 1, 2022
This commit removes all instances of `panic = "abort"` directives in
the Cargo manifest in order to mitigate Cargo bug
[#7359](rust-lang/cargo#7359) so that the
test suite can run.
SlyMarbo added a commit to ProjectSerenity/firefly that referenced this issue Feb 10, 2022
The various changes over the last year or so broke testing with
cargo xtest, but we can now use cargo test instead.

Note that we had to remove the (admittedly redundant) declarations
of `panic = "abort"` in both `dev` and `release` profiles in
Cargo.toml, thanks to rust-lang/cargo#7359.

The only thing left is the repeated deprecation warning from
bootloader, tracked in rust-osdev/bootloader#107,
which needs to be reopend at time of writing.

Signed-off-by: SlyMarbo <the.sly.marbo@googlemail.com>
SlyMarbo added a commit to ProjectSerenity/firefly that referenced this issue Feb 11, 2022
The various changes over the last year or so broke testing with
cargo xtest, but we can now use cargo test instead.

Note that we had to remove the (admittedly redundant) declarations
of `panic = "abort"` in both `dev` and `release` profiles in
Cargo.toml, thanks to rust-lang/cargo#7359.

The only thing left is the repeated deprecation warning from
bootloader, tracked in rust-osdev/bootloader#107,
which needs to be reopend at time of writing.

Signed-off-by: SlyMarbo <the.sly.marbo@googlemail.com>
SlyMarbo added a commit to ProjectSerenity/firefly that referenced this issue Feb 11, 2022
The various changes over the last year or so broke testing with
cargo xtest, but we can now use cargo test instead.

Note that we had to remove the (admittedly redundant) declarations
of `panic = "abort"` in both `dev` and `release` profiles in
Cargo.toml, thanks to rust-lang/cargo#7359.

The only thing left is the repeated deprecation warning from
bootloader, tracked in rust-osdev/bootloader#107,
which needs to be reopend at time of writing.

Signed-off-by: SlyMarbo <the.sly.marbo@googlemail.com>
@TisnKu
Copy link

TisnKu commented Apr 12, 2022

I can still repro the error reported by @phil-opp with latest rust nightly and cargo. Here is a test project: https://github.com/TisnKu/rust-duplicat-lang-item-test

Test command

cargo test --target target.json -Z build-std=core --no-run

Error:

error: duplicate lang item in crate `core` (which `rustc_std_workspace_core` depends on): `sized`.
  |
  = note: the lang item is first defined in crate `core` (which `foo` depends on)
  = note: first definition in `core` loaded from /Users/txku/projects/foo/target/target/debug/deps/libcore-537b20fcb96fe124.rlib
  = note: second definition in `core` loaded from /Users/txku/projects/foo/target/target/debug/deps/libcore-82e4bc7133bc00e1.rlib, /Users/txku/projects/foo/target/target/debug/deps/libcore-82e4bc7133bc00e1.rmeta
...

rustc +nightly -V

rustc 1.62.0-nightly (8bf93e9b6 2022-04-09)

cargo -V

cargo 1.62.0-nightly (e2e2ddd 2022-04-05)

rustup show

Default host: aarch64-apple-darwin
rustup home: /Users/txku/.rustup

installed toolchains

stable-aarch64-apple-darwin (default)
nightly-aarch64-apple-darwin

installed targets for active toolchain

aarch64-apple-darwin
thumbv7em-none-eabihf

active toolchain

nightly-aarch64-apple-darwin (directory override for '/Users/txku/projects/foo')
rustc 1.62.0-nightly (8bf93e9b6 2022-04-09)

AmberCrafter added a commit to AmberCrafter/rustos that referenced this issue Aug 22, 2022
Base on: rust-lang/cargo#7359
disable `panic=abort` in Cargo.toml

Others:
1. remove exmaple/
@crumblingstatue
Copy link

I have this simple project: https://github.com/crumblingstatue/kbswitch

xargo build --release works.
cargo build --release -Z build-std -Z build-std-features=panic_immediate_abort --target=x86_64-unknown-linux-gnu fails with the duplicate lang item errors.

smuun added a commit to smuun/raspi that referenced this issue Nov 25, 2022
Can't figure out how to implement panic enough to satisfy cargo, but
this works.
joergroedel pushed a commit to coconut-svsm/svsm that referenced this issue Mar 13, 2023
Currently, the Rust panic strategy is specified redundantly at two different
locations: once in the Cargo.toml manifest and once more in the
svsm-target.json target definition.

This by itself is not a problem, but there's a Rust issue open ([1]), which
would cause odd build errors upon 'cargo test' invocations. Removing the panic
strategy specification from Cargo.toml magically makes everything work. So do
that.

[1] rust-lang/cargo#7359

Signed-off-by: Nicolai Stange <nstange@suse.de>
@epage epage added the S-triage Status: This issue is waiting on initial triage. label Nov 2, 2023
BrandonFanti pushed a commit to BrandonFanti/rust_os_dev that referenced this issue Mar 27, 2024
 - isa-debug qemu exit
 - serial/uart out (panics and headless ops)
 - vga out
 - custom tests
   - "temporarily" removed panic=abort from Cargo.toml, until [this](rust-lang/cargo#7359) gets fixed
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

9 participants