mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Workaround for Rust having different system for templating constants to GNU as.
Having a separate file is ugly, but it allows for a single source of truth for constants Works for C, asm, zig and rust. https://stackoverflow.com/questions/79840723/shared-assembly-between-rust-and-c-using-preprocessor
This commit is contained in:
parent
2ccd3ac7f4
commit
a88f3a1690
5 changed files with 9 additions and 4 deletions
|
|
@ -6,7 +6,11 @@ _start:
|
|||
# sp is already setup by vm
|
||||
sw ra,12(sp)
|
||||
jal ra, main
|
||||
li a7, 0x138 #IOREQ_HALT (Rust assembler doesn't pick up def...)
|
||||
#if 1
|
||||
#include "non-rust-crt0-hack.s"
|
||||
#else
|
||||
li a7, {IOREQ_HALT}
|
||||
#endif
|
||||
ecall
|
||||
.section .data
|
||||
|
||||
|
|
|
|||
1
apps/non-rust-crt0-hack.S
Normal file
1
apps/non-rust-crt0-hack.S
Normal file
|
|
@ -0,0 +1 @@
|
|||
li a7,IOREQ_HALT
|
||||
|
|
@ -9,7 +9,7 @@ use core::panic::PanicInfo;
|
|||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
|
||||
// startup code
|
||||
global_asm!(include_str!("../../crt0.S")/*, IOREQ_HALT = const IOREQ_HALT*/);
|
||||
global_asm!(include_str!("../../crt0.S"), IOREQ_HALT = const IOREQ_HALT);
|
||||
|
||||
fn syscall(id: u32, n: u32) -> u32 {
|
||||
let mut value;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ pub fn build(b: *std.Build) void {
|
|||
|
||||
b.installArtifact(exe);
|
||||
|
||||
exe.addAssemblyFile(b.path("../crt0.s"));
|
||||
exe.addAssemblyFile(b.path("../crt0.S"));
|
||||
exe.setLinkerScript(b.path("../linker.ld"));
|
||||
exe.addIncludePath(b.path("../../common"));
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ pub fn build(b: *std.Build) void {
|
|||
|
||||
b.installArtifact(exe);
|
||||
|
||||
exe.addAssemblyFile(b.path("../crt0.s"));
|
||||
exe.addAssemblyFile(b.path("../crt0.S"));
|
||||
exe.setLinkerScript(b.path("../linker.ld"));
|
||||
exe.addIncludePath(b.path("../../common"));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue