Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo build failed #25

Open
bj-edward opened this issue Dec 4, 2024 · 1 comment
Open

cargo build failed #25

bj-edward opened this issue Dec 4, 2024 · 1 comment

Comments

@bj-edward
Copy link

cargo build --target riscv64gc-unknown-none-elf
Compiling libkernel v0.1.0 (/home/zhijli/Development/bj-edward/octox/src/kernel)
Compiling octox v0.1.0 (/home/zhijli/Development/bj-edward/octox)
error[E0787]: the asm! macro is not allowed in naked functions
--> src/kernel/kernelvec.rs:9:5
|
9 | / asm!(
10 | | // make room to save registers.
11 | | "addi sp, sp, -256",
12 | | // save the registers.
... |
81 | | options(noreturn)
82 | | );
| |_____^ consider using the naked_asm! macro instead

error[E0787]: the asm! macro is not allowed in naked functions
--> src/kernel/kernelvec.rs:102:5
|
102 | / asm!(
103 | | "csrrw a0, mscratch, a0",
104 | | "sd a1, 0(a0)",
105 | | "sd a2, 8(a0)",
... |
123 | | options(noreturn)
124 | | );
| |_____^ consider using the naked_asm! macro instead

error[E0787]: the asm! macro is not allowed in naked functions
--> src/kernel/swtch.rs:8:5
|
8 | / asm!(
9 | | "sd ra, 0(a0)",
10 | | "sd sp, 8(a0)",
11 | | "sd s0, 16(a0)",
... |
38 | | options(noreturn)
39 | | );
| |_____^ consider using the naked_asm! macro instead

error[E0787]: the asm! macro is not allowed in naked functions
--> src/kernel/trampoline.rs:29:9
|
29 | / asm!(
30 | | // save user a0 in sscratch so
31 | | // a0 can be used to get at TRAPFRAME
32 | | "csrw sscratch, a0",
... |
89 | | options(noreturn)
90 | | );
| |_________^ consider using the naked_asm! macro instead

error[E0787]: the asm! macro is not allowed in naked functions
--> src/kernel/trampoline.rs:104:9
|
104 | / asm!(
105 | | // switch to the user page table.
106 | | "sfence.vma zero, zero",
107 | | "csrw satp, a0",
... |
150 | | options(noreturn),
151 | | );
| |_________^ consider using the naked_asm! macro instead

warning: the feature asm_const has been stable since 1.82.0 and no longer requires an attribute to enable
--> src/kernel/lib.rs:10:12
|
10 | #![feature(asm_const)]
| ^^^^^^^^^
|
= note: #[warn(stable_features)] on by default

warning: the feature new_uninit has been stable since 1.82.0 and no longer requires an attribute to enable
--> src/kernel/lib.rs:6:66
|
6 | #![cfg_attr(all(target_os = "none", feature = "kernel"), feature(new_uninit))]
| ^^^^^^^^^^

For more information about this error, try rustc --explain E0787.
warning: libkernel (lib) generated 2 warnings
error: could not compile libkernel (lib) due to 5 previous errors; 2 warnings emitted
warning: build failed, waiting for other jobs to finish...
warning: [email protected]: nmeta 70 (boot, super, log blocks 30 inode blocks 13, bitmap blocks 25) blocks 199930 total 200000
warning: [email protected]: mkfs:balloc: first 3375 blocks have benen allocated
warning: [email protected]: mkfs:balloc: write bitmap block at sector 45

@heydocode
Copy link

heydocode commented Dec 23, 2024

Hi! I'm not a contributor or maintainer of this repo! But you can try these sollutions:

  • remove #[naked] in function signature
  • use naked_asm! instead of asm! and remove options(no_return) line, because it don't support naked_asm!.

But be careful because it's seriously modifying the actually program behavior so it will be great if an author/contributor/maintainer will pickup this issue. The deepened knowledge of this repo may be required. I plan of creating my own OS written in Rust and running on a riscv64GC board so I'm looking at existing implementations, and I have the constant frustration of non-compiling projects :(

I hope you'll be able to fix that issue or find a workaround! (If you follow one of my two proposed steps, you still get an error, not always the same: substraction overflow or an exception from kerneltrap)

Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants