rust-osdev / cargo-xbuild

Automatically cross-compiles the sysroot crates core, compiler_builtins, and alloc.
Apache License 2.0
258 stars 25 forks source link

error[E0660]: malformed inline assembly #101

Closed Chr1s-T closed 3 years ago

Chr1s-T commented 3 years ago

Hello, I prey for some help!

I was trying to learn to build a minimal system kernel from https://os.phil-opp.com/zh-CN/minimal-rust-kernel/. And when the process goes to cargo build --target x86.json, the compiler throws some errors below: error[E0660]: malformed inline assembly error[E0599]: no associated item named 'MAX' found for type 'usize' in the current scope error: Could not compile 'compiler_builtins'. 图片

My Cargo.toml configuration is here:

[package] name = "blog_os" version = "0.1.0" authors = ["chris"] edition = "2018"

[dependencies]

[unstable] build-std = ["core", "compiler_builtins", "alloc"] build-std-features = ["compiler-builtins-mem"

How to solve this problem? Please help me! Thank you very much!!!

phil-opp commented 3 years ago

It seems like you're using cargo's own build-std feature. Then you aren't using the cargo-xbuild crate at all (and you shouldn't need it). I've never seen this error, but you can try comparing your code with the post-02 branch of the phil-opp/blog_os repo, which is the repository of the "Writing an OS in Rust" blog. This branch should contain exactly the code for the "Minimal Rust Kernel" post. It is tested daily with the latest Rust nightly by our CI, so it should always work.

Chr1s-T commented 3 years ago

It seems like you're using cargo's own build-std feature. Then you aren't using the cargo-xbuild crate at all (and you shouldn't need it). I've never seen this error, but you can try comparing your code with the post-02 branch of the phil-opp/blog_os repo, which is the repository of the "Writing an OS in Rust" blog. This branch should contain exactly the code for the "Minimal Rust Kernel" post. It is tested daily with the latest Rust nightly by our CI, so it should always work.

It works! Thank you very much!