hermit-os / hermit-rs

Hermit for Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could not find `llvm-objcopy` in rustc sysroot

wucke13 opened this issue · comments

I tried to compile the example with a recent nightly toolchain (cargo 1.66.0-nightly (071eeaf21 2022-10-22), rustc 1.66.0-nightly (6e95b6da8 2022-10-22)), and I get the following error:

  error[E0425]: cannot find function `atomic_xadd` in module `core::intrinsics`
     --> /home/wucke13/.cargo/registry/src/github.com-1ecc6299db9ec823/hermit-entry-0.1.3/src/kernel.rs:127:39
      |
  127 |             let _ = core::intrinsics::atomic_xadd(core::ptr::addr_of!(self.cpu_online) as _, 1);
      |                                       ^^^^^^^^^^^ not found in `core::intrinsics`

Thanks for your interest in RustyHermit! :)

Which example did you try? One from this repository? The rust-toolchain.toml file in this repository sets the correct nightly version. Is your repository up to date with upstream?

Are you looking into RustyHermit development using this repository, or are you trying to get an application running using a released RustyHermit version? For the latter, please have a look at rusty-demo.

The latter is the case, so I will look into the demo repo. So I cloned the rusty-demo repo, cd into it an ran

$ cargo build \
    -Zbuild-std=core,alloc,std,panic_abort \
    --target x86_64-unknown-hermit \
    --release

Now I get another error:

   Compiling hermit-sys v0.4.0
error: failed to run custom build command for `hermit-sys v0.4.0`

Caused by:
  process didn't exit successfully: `/home/wucke13/documents/projects/rust/wasm-kernel/unikernel-approach/rusty-demo/target/release/build/hermit-sys-8650f5643132aa76/build-script-build` (exit status: 101)
  --- stderr
      Finished dev [unoptimized + debuginfo] target(s) in 0.04s
       Running `/home/wucke13/documents/projects/rust/wasm-kernel/unikernel-approach/rusty-demo/target/x86_64-unknown-hermit/release/build/hermit-sys-e51c1cbae7044875/out/target/debug/xtask build --arch x86_64 --profile release --target-dir /home/wucke13/documents/projects/rust/wasm-kernel/unikernel-approach/rusty-demo/target/x86_64-unknown-hermit/release/build/hermit-sys-e51c1cbae7044875/out/target --no-default-features --features 'acpi fsgsbase pci pci-ids smp'`
  Building kernel
  $ cargo build --target=x86_64-unknown-none --target-dir /home/wucke13/documents/projects/rust/wasm-kernel/unikernel-approach/rusty-demo/target/x86_64-unknown-hermit/release/build/hermit-sys-e51c1cbae7044875/out/target --no-default-features --features "acpi fsgsbase pci pci-ids smp" --profile release
      Finished release [optimized] target(s) in 0.06s
  Copying /home/wucke13/documents/projects/rust/wasm-kernel/unikernel-approach/rusty-demo/target/x86_64-unknown-hermit/release/build/hermit-sys-e51c1cbae7044875/out/target/x86_64-unknown-none/release/libhermit.a to /home/wucke13/documents/projects/rust/wasm-kernel/unikernel-approach/rusty-demo/target/x86_64-unknown-hermit/release/build/hermit-sys-e51c1cbae7044875/out/target/x86_64/release/libhermit.a
  Exporting symbols
  Error: NotFound
  thread 'main' panicked at 'assertion failed: status.success()', /home/wucke13/.cargo/registry/src/github.com-1ecc6299db9ec823/hermit-sys-0.4.0/build.rs:110:9
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/6e95b6da885f42a4e1314595089fa4295e329d11/library/std/src/panicking.rs:575:5
     1: core::panicking::panic_fmt
               at /rustc/6e95b6da885f42a4e1314595089fa4295e329d11/library/core/src/panicking.rs:65:14
     2: core::panicking::panic
               at /rustc/6e95b6da885f42a4e1314595089fa4295e329d11/library/core/src/panicking.rs:115:5
     3: build_script_build::KernelSrc::build
     4: build_script_build::main
     5: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Unfortunately its not clear what is NotFound 😄. Can you provide me with a clue? Currently I have nasm, the rust toolchain and the llvm tools in my devshell.

I found the issue: llvm_tools assumes that all llvm tools are in the same bin dir as the rustct sysroot. This is unfortunate, but fixing it is not within scope of this project.

Why isn't that the case? Is the llvm-tools-preview component not installed on your system? It should get installed automatically, as it is specified in the demo's rust-toolchain.toml.

With llvm-tools-preview installed, I get the following paths for llvm-objcopy:

# Rocky Linux 8.6
$HOME/.rustup/toolchains/nightly-2022-10-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-objcopy

# macos
$HOME/.rustup/toolchains/nightly-2022-10-19-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin/llvm-objcopy

PS: We'll need to improve the error message once we got to the bottom of this.

You are fully right.. I didn't understand that the llvm-tools-preview toolchain component is used, rather than just a normal llvm tools package (which also has equally named binaries). Now it works just fine. Thank you for the very quick and specific guidance!

For me the issue is fixed. Of course one could improve the error message a bit...