Skip to content

Commit

Permalink
pushing changes to diagnose rustc ICE
Browse files Browse the repository at this point in the history
  • Loading branch information
mark3982 committed Dec 8, 2014
1 parent 70969f4 commit cbe4a49
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 43 deletions.
9 changes: 8 additions & 1 deletion boards/realview-eb-mpcore/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_std]

extern crate core;

pub fn test() -> int {
88
}
4 changes: 3 additions & 1 deletion build
Original file line number Diff line number Diff line change
@@ -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
27 changes: 0 additions & 27 deletions core.rs

This file was deleted.

48 changes: 48 additions & 0 deletions core/core.rs
Original file line number Diff line number Diff line change
@@ -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<T>(*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!
}
20 changes: 6 additions & 14 deletions main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(*mut T);

#[start]
fn main(argc: int, argv: *const *const u8) -> int {
unsafe {
Expand Down Expand Up @@ -68,6 +58,8 @@ extern fn kstart() {
*/
let x: Box<uint> = box 3u;

board::test();

kserdbg_putc(65);
kserdbg_putc(66);
kserdbg_putc(67);
Expand Down

0 comments on commit cbe4a49

Please sign in to comment.