blog_os
blog_os copied to clipboard
error: could not compile `x86_64`
Hi, I tried to follow the "Testing" post but ran into errors after adding the x86_64 crate
error: cannot find macro `asm` in this scope
--> C:\Users\grayd\.cargo\registry\src\github.com-1ecc6299db9ec823\x86_64-0.13.2\src\instructions\interrupts.rs:18:9
|
18 | asm!("sti", options(nomem, nostack));
| ^^^
|
= note: consider importing this macro:
core::arch::asm
error: could not compile `x86_64` due to 42 previous errors
warning: build failed, waiting for other jobs to finish...
Error: Bootloader build failed.
Stderr:
cargo.toml
[package]
name = "os"
version = "0.1.0"
authors = ["Grayden Hormes <[email protected]>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bootloader = "0.9.8"
volatile = "0.2.6"
spin = "0.5.2"
x86_64 = "0.14.2"
[dependencies.lazy_static]
version = "1.0"
features = ["spin_no_std"]
[package.metadata.bootimage]
test-args = ["-device", "isa-debug-exit,iobase=0xf4,iosize=0x04"]
main.rs
#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![test_runner(crate::test_runner)]
#![reexport_test_harness_main = "test_main"]
use core::panic::PanicInfo;
mod vga_buffer;
#[no_mangle]
pub extern "C" fn _start() -> ! {
println!("Hello World{}", "!");
#[cfg(test)]
test_main();
loop {}
}
/// This function is called on panic.
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
println!("{}", info);
loop {}
}
#[cfg(test)]
fn test_runner(tests: &[&dyn Fn()]) {
println!("Running {} tests", tests.len());
for test in tests {
test();
}
/// new
exit_qemu(QemuExitCode::Success);
}
#[test_case]
fn trivial_assertion() {
print!("trivial assertion... ");
assert_eq!(1, 1);
println!("[ok]");
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u32)]
pub enum QemuExitCode {
Success = 0x10,
Failed = 0x11,
}
pub fn exit_qemu(exit_code: QemuExitCode) {
use x86_64::instructions::port::Port;
unsafe {
let mut port = Port::new(0xf4);
port.write(exit_code as u32);
}
}
I tried with x86_64 = "0.14.9" and updated my nightly from 1.5.0 to 1.6.2 but no changes.
In the output you posted, note that it is using x86_64 v0.13.2 ([...]x86_64-0.13.2[...]
) which is a very old version.
Use the latest version of x86_64
(version 0.14.9) which should correct this issue.
Also, make sure that your nightly is at least version 1.59.0.
You can also try running cargo clean
before building again.
I'm getting the same error, tried everything I could but nothing fixes it
Try running cargo tree
and post the output.
Same problem but I find it was already fixed.
try to update bootloader
to at least 0.9.20
see:
https://github.com/phil-opp/blog_os/issues/1066
As @fairjm says, uploading bootloader
to the latest version fixes the problem. Thanks everyone for your help!
I had the same issue as above but it only occurred in my windows environment and not in my WSL environment even after following the steps outlined above.
I ended up running rustup update
and that appears to have fixed the issue in my windows environment
Looks like this issue is solved.