1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-21 23:56:18 +04:00

Fix user project for new toolchain

This commit is contained in:
WangRunji 2018-08-05 10:41:51 +08:00
parent 4c402a5706
commit b61a2c9dd2
5 changed files with 34 additions and 26 deletions

View File

@ -2,4 +2,4 @@
arch := riscv32
all:
@RUST_TARGET_PATH=$(shell pwd) xargo build --target $(arch)-ucore
cargo xbuild --target $(arch)-ucore.json

View File

@ -1,6 +0,0 @@
[dependencies]
alloc = {}
[dependencies.compiler_builtins]
features = ["mem"]
stage = 1

View File

@ -5,12 +5,17 @@
"target-pointer-width": "32",
"target-c-int-width": "32",
"os": "none",
"arch": "riscv",
"arch": "riscv32",
"cpu": "generic-rv32",
"features": "+m",
"features": "",
"max-atomic-width": "32",
"linker": "riscv32-unknown-elf-ld",
"linker": "riscv64-unknown-elf-ld",
"linker-flavor": "ld",
"pre-link-args": {
"ld": [
"-melf32lriscv"
]
},
"executables": true,
"panic-strategy": "abort",
"relocation-model": "static",

View File

@ -1,4 +1,6 @@
use syscall::sys_exit;
use core::alloc::Layout;
use core::panic::PanicInfo;
#[linkage = "weak"]
#[no_mangle]
@ -7,8 +9,7 @@ fn main() {
}
#[no_mangle]
pub extern fn _start(_argc: isize, _argv: *const *const u8) -> !
{
pub extern fn _start(_argc: isize, _argv: *const *const u8) -> ! {
main();
sys_exit(0)
}
@ -16,25 +17,35 @@ pub extern fn _start(_argc: isize, _argv: *const *const u8) -> !
#[lang = "eh_personality"]
fn eh_personality() {}
#[cfg(target_arch = "x86_64")]
#[panic_implementation]
fn panic(info: &::core::panic::PanicInfo) -> ! {
fn panic(info: &PanicInfo) -> ! {
let location = info.location().unwrap();
let message = info.message().unwrap();
println!("\n\nPANIC in {} at line {}\n {}", location.file(), location.line(), message);
sys_exit(1)
}
#[cfg(target_arch = "riscv32")]
#[lang = "panic_fmt"]
#[no_mangle]
pub fn panic_fmt(fmt: ::core::fmt::Arguments, file: &'static str, line: u32, col: u32) -> ! {
println!("\n\nPANIC in {} at {}:{}\n {}", file, line, col, fmt);
sys_exit(1)
#[lang = "oom"]
fn oom(_: Layout) -> ! {
panic!("out of memory");
}
#[cfg(target_arch = "x86_64")]
#[lang = "oom"]
fn oom() -> ! {
panic!("out of memory");
#[no_mangle]
pub extern fn abort() -> ! {
sys_exit(2)
}
#[no_mangle]
pub extern fn __mulsi3(mut a: u32, mut b: u32) -> u32 {
let mut r: u32 = 0;
while a > 0 {
if a & 1 > 0 {
r += b;
}
a >>= 1;
b <<= 1;
}
r
}

View File

@ -6,8 +6,6 @@
#![feature(linkage)]
#![feature(compiler_builtins_lib)]
extern crate compiler_builtins;
#[macro_use]
pub mod syscall;
pub mod lang_items;