Add the rust std as a custom sysroot
This commit is contained in:
20
justfile
20
justfile
@@ -2,7 +2,6 @@ release := ""
|
||||
qemu_flags := ""
|
||||
cargo_flags := "" + if release != "" { "--release" } else { "" }
|
||||
bin_path := if release != "" { "target/riscv64/release" } else { "target/riscv64/debug" }
|
||||
rust_src := `rustc --print sysroot` / "lib/rustlib/src/rust/library/std/src"
|
||||
|
||||
default: run
|
||||
|
||||
@@ -13,25 +12,19 @@ mount_filesystem:
|
||||
sync_filesystem:
|
||||
sync
|
||||
|
||||
cp_std path:
|
||||
@echo "Copying {{ path }}"
|
||||
@mkdir {{ "crates/std/src" / parent_directory(path) }} -p
|
||||
@cp {{ rust_src / path }} {{ "crates/std/src" / path }}
|
||||
@perl -i -0777 -pe 's/^\s*#!?\[(un)?stable\(.*?\)\s*\]\n//gsm' {{ "crates/std/src" / path }}
|
||||
@perl -i -0777 -pe 's/^\s*#!?\[rustc_.*?\]\n//gsm' {{ "crates/std/src" / path }}
|
||||
update-std:
|
||||
@cd library/std && just update-std
|
||||
|
||||
update_std:
|
||||
@just cp_std "ffi/c_str.rs"
|
||||
@just cp_std "ffi/mod.rs"
|
||||
@just cp_std "ffi/os_str.rs"
|
||||
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" 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 }}
|
||||
RUSTFLAGS="-Clink-arg=-Tilm.ld --sysroot {{ justfile_directory() / "sysroot" }}" cargo b {{ cargo_flags }}
|
||||
just sync_filesystem
|
||||
|
||||
run: build (runner f"{{bin_path / "kernel-rust"}}")
|
||||
@@ -66,4 +59,5 @@ runner args:
|
||||
{{ qemu }} -kernel {{ args }}
|
||||
|
||||
clean:
|
||||
cd library && just clean
|
||||
cargo clean
|
||||
|
||||
Reference in New Issue
Block a user