rust-osdev / bootimage

Tool to create bootable disk images from a Rust OS kernel.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

While compiling dependencies, I get the error of missing std

anonymous12932 opened this issue · comments

error[E0463]:` can't find crate for `std`
  |
  = note: the `x86_64-blog_os-15208490549555036839` target may not support the standard library
  = note: `std` is required by `serde` because it does not declare `#![no_std]`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

Code:

// src/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() -> ! {
    // this function is the entry point, since the linker looks for a function
    // named `_start` by default
    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 {}
}

.cargo/config.toml:

[unstable]
build-std-features = ["compiler-builtins-mem"]
build-std = ["core", "compiler_builtins"]
[build]
target = "x86_64-blog_os.json"

Should I delete the no_std line? or build using "-Zbuild-std"
What did I do wrong? Maybe it's obvious, but I can be inattentive. .

The problem was that the config.toml file was common to all projects.