Fixed linking and memory allocation for rust

Now rlibs are actually linked to programs. Target files have been
modified to not generate code that requires compiler-rt. Added a target
for libstd-rust, but it's very broken right now. Moved alloc_system to
the libports folder because either a memory allocator needs to be
written in rust or posix_memalign needs to be implemented. Changed
liblibc to use freebsd as the OS instead of netbsd. Added a library with
unwind dummy functions.

Rust relies on atomic builtins, which are not implemented in libgcc for
ARM. One was implemented in rust, which was sufficient to get the
current rust test to run. Rust libs were added into the group of libs
for the linker so order no longer matters. The raspberry pi now uses an
armv6 target.
This commit is contained in:
Waylon Cude
2016-02-28 22:44:04 -08:00
committed by Christian Helmuth
parent ab88599682
commit 1e95af5bab
21 changed files with 397 additions and 16 deletions

View File

@ -1,9 +1,11 @@
{
"llvm-target": "arm-pc-genode-elf",
"llvm-target": "armv6-pc-genode-gnueabi",
"target-endian": "little",
"target-pointer-width": "32",
"arch": "arm",
"os": "genode",
"cpu": "generic",
"no_compiler_rt": true
"env": "armv6",
"no_compiler_rt": true,
"features": "+v6"
}

View File

@ -0,0 +1,11 @@
{
"llvm-target": "armv7-pc-genode-gnueabi",
"target-endian": "little",
"target-pointer-width": "32",
"arch": "arm",
"os": "genode",
"cpu": "generic",
"env": "armv7",
"no_compiler_rt": true,
"features": "+v7"
}

View File

@ -4,5 +4,6 @@
"target-endian": "little",
"target-pointer-width": "64",
"arch": "riscv",
"os": "genode"
"os": "genode",
"no_compiler_rt": true
}

View File

@ -3,5 +3,6 @@
"target-endian": "little",
"target-pointer-width": "32",
"arch": "x86",
"os": "genode"
"os": "genode",
"no_compiler_rt": true
}

View File

@ -4,5 +4,6 @@
"target-endian": "little",
"target-pointer-width": "64",
"arch": "x86_64",
"os": "genode"
"os": "genode",
"no_compiler_rt": true
}

View File

@ -1,18 +1,20 @@
#![no_std]
#![feature(lang_items,collections)]
#![feature(lang_items,collections,alloc)]
extern crate collections;
extern crate alloc;
extern crate libc;
use alloc::boxed::Box;
extern "C"{
fn print_num(num: libc::c_int);
}
#[no_mangle]
pub fn main() -> libc::c_int{
let n = Box::new(42);
unsafe {
print_num(42);
print_num(*n);
}
0
}
#[lang="panic_fmt"]
#[no_mangle]
pub fn panic_fmt() -> ! { loop{} }

View File

@ -1,4 +1,4 @@
TARGET = rust-test
SRC_RS = main.rs
SRC_CC = printf.cc
LIBS = libcore-rust libcollections-rust base libc librustc_unicode-rust liballoc-rust liblibc-rust liballoc_system-rust
LIBS = libcore-rust libcollections-rust base librustc_unicode-rust liballoc-rust liblibc-rust liballoc_system-rust