From cbe4a49a9c772cfe44b81d1e7dce3eb624f56719 Mon Sep 17 00:00:00 2001 From: kmcguire Date: Sun, 7 Dec 2014 22:16:43 -0600 Subject: [PATCH] pushing changes to diagnose rustc ICE --- boards/realview-eb-mpcore/board.rs | 9 +++++- build | 4 ++- core.rs | 27 ----------------- core/core.rs | 48 ++++++++++++++++++++++++++++++ main.rs | 20 ++++--------- 5 files changed, 65 insertions(+), 43 deletions(-) delete mode 100644 core.rs create mode 100644 core/core.rs diff --git a/boards/realview-eb-mpcore/board.rs b/boards/realview-eb-mpcore/board.rs index 09bff6b..a6b580d 100644 --- a/boards/realview-eb-mpcore/board.rs +++ b/boards/realview-eb-mpcore/board.rs @@ -5,4 +5,11 @@ It is produced at this time as a Rust library which is then used by the kernel when it is built. -*/ \ No newline at end of file +*/ +#![no_std] + +extern crate core; + +pub fn test() -> int { + 88 +} \ No newline at end of file diff --git a/build b/build index ba75467..a1224bc 100644 --- a/build +++ b/build @@ -1,3 +1,5 @@ -rustc main.rs --opt-level 3 --emit=obj --target=arm-unknown-linux-gnueabi +#rustc --crate-type rlib ./boards/realview-eb-mpcore/board.rs --target=arm-unknown-linux-gnueabi +#rustc --crate-type rlib ./core/core.rs --target=arm-unknown-linux-gnueabi +rustc -L . main.rs --opt-level 3 --emit=obj --target=arm-unknown-linux-gnueabi arm-ld main.o -o rustk.elf arm-objcopy -j .text -O binary rustk.elf rustk.bin diff --git a/core.rs b/core.rs deleted file mode 100644 index 4f3fd85..0000000 --- a/core.rs +++ /dev/null @@ -1,27 +0,0 @@ -struct Global { - heapoffset: uint, - curheapndx: uint -} - -static mut GLOBAL: Global = Global { - heapoffset: 0, - curheapndx: 0 -}; - -#[lang="exchange_malloc"] -#[inline] -unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 { - // The most simple heap possible! - let ptr: uint; - ptr = GLOBAL.heapoffset + GLOBAL.curheapndx; - GLOBAL.curheapndx += size; - - ptr as *mut u8 -} - -#[lang="exchange_free"] -#[inline] -unsafe fn exchange_free(ptr: *mut u8, old_size: uint, align: uint) { - // The most simple heap possible. It does not support - // deallocation! -} \ No newline at end of file diff --git a/core/core.rs b/core/core.rs new file mode 100644 index 0000000..e9fa388 --- /dev/null +++ b/core/core.rs @@ -0,0 +1,48 @@ +#![feature(lang_items)] +#![no_std] + +#[lang="sized"] +trait Sized {} +#[lang="sync"] +trait Sync {} + +#[lang = "stack_exhausted"] extern fn stack_exhausted() {} +#[lang = "eh_personality"] extern fn eh_personality() {} +#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} } + +#[lang = "exchange_heap"] +#[experimental = "may be renamed; uncertain about custom allocator design"] +pub static HEAP: () = (); + +/// A type that represents a uniquely-owned value. +#[lang = "owned_box"] +#[unstable = "custom allocators will add an additional type parameter (with default)"] +pub struct Box(*mut T); + +struct Global { + heapoffset: uint, + curheapndx: uint +} + +static mut GLOBAL: Global = Global { + heapoffset: 0, + curheapndx: 0 +}; + +#[lang="exchange_malloc"] +#[inline] +unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 { + // The most simple heap possible! + let ptr: uint; + ptr = GLOBAL.heapoffset + GLOBAL.curheapndx; + GLOBAL.curheapndx += size; + + ptr as *mut u8 +} + +#[lang="exchange_free"] +#[inline] +unsafe fn exchange_free(ptr: *mut u8, old_size: uint, align: uint) { + // The most simple heap possible. It does not support + // deallocation! +} \ No newline at end of file diff --git a/main.rs b/main.rs index 3c6d4b9..21e480b 100644 --- a/main.rs +++ b/main.rs @@ -3,25 +3,15 @@ #![allow(unused_variables)] #![allow(dead_code)] #![feature(asm)] +#![feature(globs)] -mod core; +extern crate board; +extern crate core; -#[lang="sized"] -trait Sized {} -#[lang="sync"] -trait Sync {} +use core::*; static GDT: [u32, ..5] = [0, 1, 2, 3, 4]; -#[lang = "exchange_heap"] -#[experimental = "may be renamed; uncertain about custom allocator design"] -pub static HEAP: () = (); - -/// A type that represents a uniquely-owned value. -#[lang = "owned_box"] -#[unstable = "custom allocators will add an additional type parameter (with default)"] -pub struct Box(*mut T); - #[start] fn main(argc: int, argv: *const *const u8) -> int { unsafe { @@ -68,6 +58,8 @@ extern fn kstart() { */ let x: Box = box 3u; + board::test(); + kserdbg_putc(65); kserdbg_putc(66); kserdbg_putc(67);