From 37564cb9fd178f58b9e4c51f4549a12b5922ebb8 Mon Sep 17 00:00:00 2001 From: WangRunji Date: Fri, 6 Jul 2018 01:24:35 +0800 Subject: [PATCH] Change build target to `riscv32ia_unknown_none` --- Cargo.toml | 2 +- Makefile | 3 --- docs/RISCV.md | 14 ++++++++++++++ riscv32-blog_os.json | 30 ++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 riscv32-blog_os.json diff --git a/Cargo.toml b/Cargo.toml index 83b36b2..070ca7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ simple-filesystem = { git = "https://github.com/wangrunji0408/SimpleFileSystem-R bit-allocator = { path = "crate/bit-allocator" } ucore-memory = { path = "crate/memory" } -[target.riscv32i-unknown-none.dependencies] +[target.riscv32-blog_os.dependencies] riscv = { path = "crate/riscv" } bbl = { path = "crate/bbl" } diff --git a/Makefile b/Makefile index 9f54ade..737f1bf 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,6 @@ arch ?= riscv32 kernel := build/kernel-$(arch).bin iso := build/os-$(arch).iso target ?= $(arch)-blog_os -ifeq ($(arch), riscv32) -target := riscv32i-unknown-none -endif mode ?= debug rust_lib := target/$(target)/$(mode)/librust_ucore.a diff --git a/docs/RISCV.md b/docs/RISCV.md index f24810a..a4cd666 100644 --- a/docs/RISCV.md +++ b/docs/RISCV.md @@ -7,6 +7,20 @@ 具体配置过程详见[Dockerfile](../riscv-env/Dockerfile) +## Rust-RISCV + +### 目标指令集:RISCV32IA + +target: riscv32ia_unknown_none + +由于工具链二进制版本尚未内置`riscv32ia_unknown_none`的target,因此需提供配置文件:`riscv32-blog_os.json`。 + +为什么要用原子指令扩展? + +RustOS依赖的库中,大部分都使用了Rust核心库的原子操作(core::sync::atomic)。 + +如果目标指令集不支持原子操作,会导致无法编译。 + ## BootLoader 参考[bbl-ucore](https://github.com/ring00/bbl-ucore)及后续的[ucore_os_lab for RISCV32](https://github.com/chyyuu/ucore_os_lab/tree/riscv32-priv-1.10),使用[bbl](https://github.com/riscv/riscv-pk.git)作为BootLoader。 diff --git a/riscv32-blog_os.json b/riscv32-blog_os.json new file mode 100644 index 0000000..291cdeb --- /dev/null +++ b/riscv32-blog_os.json @@ -0,0 +1,30 @@ +{ + "llvm-target": "riscv32", + "data-layout": "e-m:e-p:32:32-i64:64-n32-S128", + "target-endian": "little", + "target-pointer-width": "32", + "target-c-int-width": "32", + "os": "none", + "arch": "riscv", + "cpu": "generic-rv32", + "features": "+a", + "max-atomic-width": "32", + "linker": "ld.lld", + "linker-flavor": "ld", + "executables": true, + "panic-strategy": "abort", + "relocation-model": "static", + "abi-blacklist": [ + "cdecl", + "stdcall", + "fastcall", + "vectorcall", + "thiscall", + "aapcs", + "win64", + "sysv64", + "ptx-kernel", + "msp430-interrupt", + "x86-interrupt" + ] +} \ No newline at end of file