trapframe-rs
trapframe-rs copied to clipboard
fix(riscv): don't split stateful assembly directives across global_asm instances
Relying on stateful directives to persist across inline assembly instances is forbidden: https://doc.rust-lang.org/reference/inline-assembly.html#r-asm.directives.stateful
Without this patch, in some scenarios, trapframe fails to compile, since the macros XLENB, LOAD_SP, and STORE_SP may not be available:
error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
|
note: instantiated into assembly here
--> <inline asm>:17:18
|
17 | addi sp, sp, -34 * XLENB
| ^
error: unrecognized instruction mnemonic
|
note: instantiated into assembly here
--> <inline asm>:21:5
|
21 | STORE_SP x1, 1
| ^
...
error: could not compile `trapframe` (lib) due to 99 previous errors
CC: @simonschoening
This is the same issue as https://github.com/rust-embedded/riscv/issues/321, which was resolved in https://github.com/rust-embedded/riscv/pull/322.