Starts adding rust in the toolchain

This commit is contained in:
2025-11-12 22:05:25 +01:00
parent 7bb8b993ae
commit 8326c1f169
11 changed files with 104 additions and 4 deletions

View File

@@ -0,0 +1,14 @@
[build]
target = "riscv64i.json"
[target.riscv64i]
linker = "riscv64-unknown-elf-ld"
# linker = "rust-lld"
rustflags = [
# "-C", "link-arg=-nostartfiles",
"-C", "link-arg=-T../link.ld",
]
[unstable]
build-std = ["core", "compiler_builtins"]

3
bench/programs_rust/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
.helix/
target/
Cargo.lock

View File

@@ -0,0 +1,13 @@
[workspace]
resolver = "3"
members = ["fpga_lib", "hello_rust"]
[profile.release]
panic = "abort"
codegen-units = 1 # better optimizations
lto = true # better optimizations
strip = true
opt-level = "z"
[profile.dev]
panic = "abort"

View File

@@ -0,0 +1,6 @@
[package]
name = "fpga_lib"
version = "0.1.0"
edition = "2024"
[dependencies]

View File

@@ -0,0 +1,11 @@
#![no_std]
#[macro_export]
macro_rules! panic_handler {
() => {
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
};
}

View File

@@ -0,0 +1,7 @@
[package]
name = "hello_rust"
version = "0.1.0"
edition = "2024"
[dependencies]
fpga_lib = { path = "../fpga_lib" }

View File

@@ -0,0 +1,18 @@
#![no_std]
#![no_main]
use core::arch::asm;
use fpga_lib::panic_handler;
panic_handler! {}
#[unsafe(no_mangle)]
pub extern "C" fn _start() -> ! {
unsafe {
asm! {
"li x31, 0xdead0"
}
}
loop {}
}

View File

@@ -0,0 +1,21 @@
{
"llvm-target": "riscv64",
"llvm-abiname": "lp64",
"abi": "lp64",
"data-layout": "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128",
"target-endian": "little",
"target-pointer-width": 64,
"arch": "riscv64",
"os": "none",
"vendor": "unknown",
"env": "",
"features": "+i",
"linker-flavor": "ld.lld",
"linker": "riscv64-unknown-elf-ld",
"executables": true,
"panic-strategy": "abort",
"relocation-model": "static",
"disable-redzone": true,
"emit-debug-gdb-scripts": false,
"eh-frame-header": false
}

View File

@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly"