Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Error thrown when using Workspace project #54

Copy link
Copy link
Closed
@nabilmerk

Description

@nabilmerk
Issue body actions

Hi,

First of all, I want to say big thanks because your blog that explains quite well how to start with kernel OS using Rust! This language is always compared to C language but it's very rare to find an interesting blog about how to write kernel OS in Rust.

When I'm trying to play with A Minimal Rust Kernel example, I actually got an error from cargo bootimage. I don't really know where the error comes from but I've setup a workspace project compares to your example such that my directory looks like:

  • dummy_os/
    • Cargo.toml
    • .cargo/
      • config
    • src/
      • dummy_os/
        • Cargo.toml
        • main.rs
    • x86_64-dummy_os.json

The top Cargo.toml:

[workspace]
members = [
    "src/dummy_os",
]

# the profile used for `cargo build`
[profile.dev]
panic = "abort" # disable stack unwinding on panic

# the profile used for `cargo build --release`
[profile.release]
panic = "abort" # disable stack unwinding on panic

The .cargo/config:

[build]
target = "x86_64-dummy_os.json"

[target.'cfg(target_os = "none")']
runner = "bootimage runner"

The src/dummy_os/Cargo.toml:

[package]
name = "dummy_os"
version = "0.1.0"
edition = "2018"

[[bin]]
name = "dummy_os"
path = "main.rs"

[dependencies]
bootloader = "*"

The src/dummy_os/main.rs:

#![no_std] // don't link the Rust standard library
#![no_main] // disable all Rust-level entry points

use core::panic::PanicInfo;

/// This function is called on panic.
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
    loop {}
}

static HELLO: &[u8] = b"Hello World!";

#[no_mangle] // don't mangle the name of this function
pub extern "C" fn _start() -> ! {
    let vga_buffer = 0xb8000 as *mut u8;

    for (i, &byte) in HELLO.iter().enumerate() {
	unsafe {
	    *vga_buffer.offset(i as isize * 2) = byte;
	    *vga_buffer.offset(i as isize * 2 + 1) = 0xb;
	}
    }
    
    loop {}
}

Here's the error:

Building kernel
WARNING: There is no root package to read the cargo-xbuild config from.
    Updating crates.io index
   Compiling core v0.0.0 (~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
   Compiling compiler_builtins v0.1.27
   Compiling rustc-std-workspace-core v1.99.0 (~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/tools/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/tmp/cargo-xbuild.B83qpoInHGhF)
    Finished release [optimized] target(s) in 39.40s
   Compiling bootloader v0.9.2
   Compiling dummy_os v0.1.0 (~/dummy_os/src/dummy_os)
    Finished dev [unoptimized + debuginfo] target(s) in 0.94s
Error: Could not find required key `packages[manifest_path = `~/dummy_os/Cargo.toml`]` in cargo metadata output

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.