Skip to content

duplicate lang item `panic_impl' #1175

Closed

Description

@sarocu

What happened?

Compiling a simple guest example fails with:

error[E0152]: found duplicate lang item `panic_impl`
   --> /home/sarocu/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyperlight-guest-bin-0.12.0/src/lib.rs:139:1
    |
139 | / fn panic(info: &core::panic::PanicInfo) -> ! {
140 | |     _panic_handler(info)
141 | | }
    | |_^
    |
    = note: the lang item is first defined in crate `std` (which `tracing` depends on)
    = note: first definition in `std` loaded from /home/sarocu/.rustup/toolchains/1.89-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-099ea48a26be4ce8.rlib
    = note: second definition in the local crate (`hyperlight_guest_bin`)

Dependencies:

[dependencies]
hyperlight-common = "0.12.0"
hyperlight-guest = "0.12.0"
hyperlight-guest-bin = "0.12.0"
hyperlight-guest-tracing = "0.12.0"

Rust:

cargo --version
cargo 1.89.0 (c24e10642 2025-06-23)

What did you expect to happen?

Successful build

Steps to reproduce the behavior

  1. Install the shared dependencies in a new project
  2. Copy the example snippet for a guest hyperlight binary in the README
  3. cargo build

Hyperlight Version

0.12.0

OS version

             /////////////                
         /////////////////////            -------------
      ///////*767////////////////         OS: Pop!_OS 24.04 LTS x86_64
    //////7676767676*//////////////       Kernel: 6.17.9-76061709-generic
   /////76767//7676767//////////////      Uptime: 3 hours, 32 mins
  /////767676///*76767///////////////     Packages: 2082 (dpkg), 13 (flatpak)
 ///////767676///76767.///7676*///////    Shell: bash 5.2.21
/////////767676//76767///767676////////   Resolution: 3440x1440
//////////76767676767////76767/////////   DE: COSMIC
///////////76767676//////7676//////////   Theme: adw-gtk3 [GTK3]
////////////,7676,///////767///////////   Icons: Cosmic [GTK3]
/////////////*7676///////76////////////   Terminal: cosmic-term
///////////////7676////////////////////   CPU: AMD Ryzen 7 3700X (16) @ 3.800GHz
 ///////////////7676///767////////////    GPU: NVIDIA 09:00.0 NVIDIA Corporation Device 2d04
  //////////////////////'////////////     Memory: 8201MiB / 31999MiB
   //////.7676767676767676767,//////
    /////767676767676767676767/////
      ///////////////////////////
         /////////////////////
             /////////////

Additional Information

No response

Activity

  1. ludfjig commented on Jan 17, 2026

    @ludfjig
    Contributor

    Hello and thanks for the report! Would you mind speciying exactly how you compiled the guest? We mostly use cargo-hyperlight to build guests which automatically sets up certain things. Have you tried cargo hyperlight build instead, which I also think is what our README uses?

  2. jsturtevant commented on Jan 17, 2026

    @jsturtevant
    Contributor

    What does your guest look like? you will need to have: (see https://github.com/hyperlight-dev/hyperlight?tab=readme-ov-file#guest)

    #![no_std]
    #![no_main]
    extern crate alloc;
    

    There are some additional settings required to build and link everything properly. The easiest way to get it built is:

    cargo install --locked cargo-hyperlight
    cargo hyperlight build
    

    if your still having trouble, if you could provider a minimal example and the command you ran that would help

  3. sarocu commented on Jan 20, 2026

    @sarocu
    Author

    @jsturtevant I attempted to build with that exact file. I am using the published crates in a fresh project rather than cloning the repo so maybe I am just misunderstanding something with the architecture.

    Seems to be a dependency issue; @ludfjig when I use that build command I see a lot of errors that are related to building deps:

    error: could not compile `serde_core` (lib) due to 5866 previous errors
    
    thread 'main' panicked at /home/sarocu/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cargo-hyperlight-0.1.5/src/main.rs:28:10:
    Failed to execute cargo: Failed to execute cargo
    
    Caused by:
        Command exited with code 101:
        AR_x86_64-hyperlight-none="/usr/bin/ar" BINDGEN_EXTRA_CLANG_ARGS="--target=x86_64-unknown-linux-none -U__linux__ -fPIC -fno-stack-protector -fstack-clash-protection -mstack-probe-size=4096 -mno-red-zone -nostdinc -DHYPERLIGHT=1 -D__HYPERLIGHT__=1  -isystem /home/sarocu/Projects/heyvm/guest/target/sysroot/lib/rustlib/x86_64-hyperlight-none/include --target=x86_64-unknown-linux-none -U__linux__ -fPIC -fno-stack-protector -fstack-clash-protection -mstack-probe-size=4096 -mno-red-zone -nostdinc -DHYPERLIGHT=1 -D__HYPERLIGHT__=1  -isystem /home/sarocu/Projects/heyvm/guest/target/sysroot/lib/rustlib/x86_64-hyperlight-none/include" CARGO_BUILD_TARGET="x86_64-hyperlight-none" CC_x86_64-hyperlight-none="/usr/bin/clang" CFLAGS_x86_64-hyperlight-none="--target=x86_64-unknown-linux-none -U__linux__ -fPIC -fno-stack-protector -fstack-clash-protection -mstack-probe-size=4096 -mno-red-zone -nostdinc -DHYPERLIGHT=1 -D__HYPERLIGHT__=1  -isystem /home/sarocu/Projects/heyvm/guest/target/sysroot/lib/rustlib/x86_64-hyperlight-none/include" CLANG_PATH="/usr/bin/clang" RUSTFLAGS="--sysroot /home/sarocu/Projects/heyvm/guest/target/sysroot --cfg=hyperlight --check-cfg=cfg(hyperlight) -Clink-args=-eentrypoint" RUSTUP_TOOLCHAIN="1.89-x86_64-unknown-linux-gnu" "/home/sarocu/.rustup/toolchains/1.89-x86_64-unknown-linux-gnu/bin/cargo" "build"
    
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    
  4. ludfjig commented on Jan 20, 2026

    @ludfjig
    Contributor

    Are you able to build the guest checked into this repo with the command using command just guests in root folder? The issue could also potentially be because one of

    [dependencies]
    hyperlight-common = "0.12.0"
    hyperlight-guest = "0.12.0"
    hyperlight-guest-bin = "0.12.0"
    hyperlight-guest-tracing = "0.12.0" 
    

    pulls in std. Can you try adding default-features = false on these (at least hyperlight-common).

  5. sarocu commented on Jan 21, 2026

    @sarocu
    Author

    @ludfjig building inside of this repo works with the just guests command

    Added default-features = false and tried the 0.11.0 release as well and still see errors

  6. ludfjig commented on Jan 22, 2026

    @ludfjig
    Contributor

    @ludfjig building inside of this repo works with the just guests command

    Added default-features = false and tried the 0.11.0 release as well and still see errors

    Thanks for checking. I tried it myself and managed to make the following work. It's harder than I thought, and the error messages were pretty cryptic. In addition I needed to do a full cargo clean to get it to work.

    main.rs:

    #![no_std]
    #![no_main]
    
    extern crate alloc;
    extern crate hyperlight_guest_bin;
    
    #[unsafe(no_mangle)]
    pub extern "C" fn hyperlight_main() {
        unimplemented!()
    }
    
    #[unsafe(no_mangle)]
    pub fn guest_dispatch_function(
        _function_call: hyperlight_common::flatbuffer_wrappers::function_call::FunctionCall,
    ) -> hyperlight_guest::error::Result<alloc::vec::Vec<u8>> {
        unimplemented!()
    }

    Cargo.toml

    [package]
    name = "test_guest"
    version = "0.1.0"
    edition = "2024"
    
    [dependencies]
    hyperlight-guest = { version = "0.12.0" }
    hyperlight-guest-bin = { version = "0.12.0"}
    hyperlight-common = { version = "0.12.0", default-features = false }

    Please let me know if the above works for you! We have been thinking about making some tool to scaffold a new guest, and I think that definitely would be useful and potentially avoid problems like these

  7. sarocu commented on Jan 22, 2026

    @sarocu
    Author

    That works!

    Some sort of tool would be great, maybe a quick edit on the README. Appreciate the assist!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions