perlindgren / syncrim

15 stars 4 forks source link

Let cargo handle the compilation of RISC-V assembly #56

Closed onsdagens closed 11 months ago

onsdagens commented 11 months ago

This adds a binary crate courtesy of @perlindgren which allows us to use cargo to compile the provided RISC-V assembly.

The solution is really funky, via Commands we copy the source file and linker script into the ./riscv_asm binary crate, compile it with cargo build --release , then move the compilation results back into ./ .

The binary crate consists of basically global_asm!(include_str!("<ASM_SOURCE_FILE_PATH>")), and a rustc flag to use the linker script.

I tried making it Windows compatible, but am unable to test it, so would appreciate some help there.

perlindgren commented 11 months ago

During compilation the asm.s and memory.x is copied to the riscv_asm folder and run there to generate the binary to execute. This is behavior is currently hardcoded, we can think of improving this procedure when the RISC simulator is compiled as a standalone binary.