From 387e586086c172de529f14ffd54131cc99d4eae6 Mon Sep 17 00:00:00 2001 From: Julien THILLARD Date: Fri, 20 Mar 2026 10:45:54 +0100 Subject: [PATCH] Add more from the std --- .cargo/config.toml | 3 +-- crates/kernel-macros/Cargo.toml | 2 +- justfile | 5 ++--- library/.gitignore | 1 + library/std/.gitignore | 2 ++ user.ld | 35 --------------------------------- 6 files changed, 7 insertions(+), 41 deletions(-) delete mode 100644 user.ld diff --git a/.cargo/config.toml b/.cargo/config.toml index 05b1498..41f20d6 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -3,10 +3,9 @@ target = "riscv64.json" [unstable] json-target-spec = true -# build-std = [] -# build-std-features = ["compiler-builtins-mem"] [target.riscv64] rustflags = [ "-C", "link-arg=-Tilm.ld", + "--sysroot", "sysroot" ] diff --git a/crates/kernel-macros/Cargo.toml b/crates/kernel-macros/Cargo.toml index 5832c35..ae9e488 100644 --- a/crates/kernel-macros/Cargo.toml +++ b/crates/kernel-macros/Cargo.toml @@ -7,6 +7,6 @@ edition = "2024" proc-macro = true [dependencies] -image = "0.25" +image = { version = "0.25", default-features = false, features = ["png"] } syn = { version = "2", features = ["full"] } zyn = "0.5" diff --git a/justfile b/justfile index b6f0a78..c2753dc 100644 --- a/justfile +++ b/justfile @@ -1,7 +1,6 @@ release := "" qemu_flags := "" cargo_flags := "" + if release != "" { "--release" } else { "" } -KERNEL_FLAGS := "-Zbuild-std=core,compiler_builtins,alloc -Zbuild-std-features=compiler-builtins-mem" bin_path := if release != "" { "target/riscv64/release" } else { "target/riscv64/debug" } default: run @@ -20,12 +19,12 @@ build-sysroot: @cd library/std && just build-sysroot build_user_prog prog: - RUSTFLAGS="-C relocation-model=pic -C link-arg=-Tuser.ld -C link-arg=-pie --sysroot {{ justfile_directory() / "sysroot" }}" cargo b {{ cargo_flags }} --package {{ prog }} + RUSTFLAGS="-C relocation-model=pic -C link-arg=-pie --sysroot {{ justfile_directory() / "sysroot" }}" cargo b {{ cargo_flags }} --package {{ prog }} riscv64-elf-strip {{ bin_path / prog }} cp {{ bin_path / prog }} {{ "mnt/usr/bin" / prog }} build: mount_filesystem (map_dir "user" f"just release=\"{{release}}\" cargo_flags=\"{{cargo_flags}}\" build_user_prog") - cargo b {{ cargo_flags }} {{ KERNEL_FLAGS }} + RUSTFLAGS="-Clink-arg=-Tilm.ld --sysroot {{ justfile_directory() / "sysroot" }}" cargo b {{ cargo_flags }} just sync_filesystem run: build (runner f"{{bin_path / "kernel-rust"}}") diff --git a/library/.gitignore b/library/.gitignore index 7a6f012..efc0ca5 100644 --- a/library/.gitignore +++ b/library/.gitignore @@ -12,5 +12,6 @@ rustc-std-workspace-alloc rustc-std-workspace-core rustc-std-workspace-std windows_link +profiler_builtins test proc_macro diff --git a/library/std/.gitignore b/library/std/.gitignore index 8f65c3a..6abdf1c 100644 --- a/library/std/.gitignore +++ b/library/std/.gitignore @@ -1,3 +1,5 @@ +build.rs + src/alloc.rs src/ascii.rs src/backtrace.rs diff --git a/user.ld b/user.ld deleted file mode 100644 index f1e4581..0000000 --- a/user.ld +++ /dev/null @@ -1,35 +0,0 @@ -/* - * ld directives the for barmetal RISCV - */ -OUTPUT_ARCH(riscv) -ENTRY(_start) - -MEMORY { - RAM (wxa) : ORIGIN = 0x0, LENGTH = 128M -} - -SECTIONS { - . = 0x0; - .text : { - KEEP(*(.text._start)) - - *(.text .text.*) - } > RAM - - .rodata : { - *(.rodata .rodata.*) - } > RAM - - .data : { - *(.data .data.*) - } > RAM - - .bss : ALIGN(8) { - __bss_start = .; - *(.bss .bss.*) - __bss_end = .; - } > RAM - - _heap_start = ALIGN(8); - _heap_end = ORIGIN(RAM) + LENGTH(RAM); -}