Skip to content

Commit cbe4a49

Browse files
committed
pushing changes to diagnose rustc ICE
1 parent 70969f4 commit cbe4a49

File tree

5 files changed

+65
-43
lines changed

5 files changed

+65
-43
lines changed

boards/realview-eb-mpcore/board.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@
55
66
It is produced at this time as a Rust library which is then used by
77
the kernel when it is built.
8-
*/
8+
*/
9+
#![no_std]
10+
11+
extern crate core;
12+
13+
pub fn test() -> int {
14+
88
15+
}

build

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
rustc main.rs --opt-level 3 --emit=obj --target=arm-unknown-linux-gnueabi
1+
#rustc --crate-type rlib ./boards/realview-eb-mpcore/board.rs --target=arm-unknown-linux-gnueabi
2+
#rustc --crate-type rlib ./core/core.rs --target=arm-unknown-linux-gnueabi
3+
rustc -L . main.rs --opt-level 3 --emit=obj --target=arm-unknown-linux-gnueabi
24
arm-ld main.o -o rustk.elf
35
arm-objcopy -j .text -O binary rustk.elf rustk.bin

core.rs

-27
This file was deleted.

core/core.rs

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#![feature(lang_items)]
2+
#![no_std]
3+
4+
#[lang="sized"]
5+
trait Sized {}
6+
#[lang="sync"]
7+
trait Sync {}
8+
9+
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
10+
#[lang = "eh_personality"] extern fn eh_personality() {}
11+
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }
12+
13+
#[lang = "exchange_heap"]
14+
#[experimental = "may be renamed; uncertain about custom allocator design"]
15+
pub static HEAP: () = ();
16+
17+
/// A type that represents a uniquely-owned value.
18+
#[lang = "owned_box"]
19+
#[unstable = "custom allocators will add an additional type parameter (with default)"]
20+
pub struct Box<T>(*mut T);
21+
22+
struct Global {
23+
heapoffset: uint,
24+
curheapndx: uint
25+
}
26+
27+
static mut GLOBAL: Global = Global {
28+
heapoffset: 0,
29+
curheapndx: 0
30+
};
31+
32+
#[lang="exchange_malloc"]
33+
#[inline]
34+
unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 {
35+
// The most simple heap possible!
36+
let ptr: uint;
37+
ptr = GLOBAL.heapoffset + GLOBAL.curheapndx;
38+
GLOBAL.curheapndx += size;
39+
40+
ptr as *mut u8
41+
}
42+
43+
#[lang="exchange_free"]
44+
#[inline]
45+
unsafe fn exchange_free(ptr: *mut u8, old_size: uint, align: uint) {
46+
// The most simple heap possible. It does not support
47+
// deallocation!
48+
}

main.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,15 @@
33
#![allow(unused_variables)]
44
#![allow(dead_code)]
55
#![feature(asm)]
6+
#![feature(globs)]
67

7-
mod core;
8+
extern crate board;
9+
extern crate core;
810

9-
#[lang="sized"]
10-
trait Sized {}
11-
#[lang="sync"]
12-
trait Sync {}
11+
use core::*;
1312

1413
static GDT: [u32, ..5] = [0, 1, 2, 3, 4];
1514

16-
#[lang = "exchange_heap"]
17-
#[experimental = "may be renamed; uncertain about custom allocator design"]
18-
pub static HEAP: () = ();
19-
20-
/// A type that represents a uniquely-owned value.
21-
#[lang = "owned_box"]
22-
#[unstable = "custom allocators will add an additional type parameter (with default)"]
23-
pub struct Box<T>(*mut T);
24-
2515
#[start]
2616
fn main(argc: int, argv: *const *const u8) -> int {
2717
unsafe {
@@ -68,6 +58,8 @@ extern fn kstart() {
6858
*/
6959
let x: Box<uint> = box 3u;
7060

61+
board::test();
62+
7163
kserdbg_putc(65);
7264
kserdbg_putc(66);
7365
kserdbg_putc(67);

0 commit comments

Comments
 (0)