Skip to content
This repository was archived by the owner on Jul 6, 2019. It is now read-only.

Commit 04e81fb

Browse files
committed
Merge pull request #113 from errordeveloper/rlibc
Use rlibc crate Reviewed-by: farcaller
2 parents d35748d + 393a230 commit 04e81fb

File tree

4 files changed

+15
-46
lines changed

4 files changed

+15
-46
lines changed

Rakefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ compile_rust :hamcrest_crate, {
1818
do_not_collect_rust_deps: true,
1919
}
2020

21+
# cross-compiled librlibc
22+
compile_rust :rlibc_crate, {
23+
source: 'thirdparty/librlibc/lib.rs'.in_root,
24+
produce: 'thirdparty/librlibc/lib.rs'.in_root.as_rlib.in_build,
25+
out_dir: true,
26+
recompile_on: :triple,
27+
}
28+
2129
# cross-compiled libcore
2230
compile_rust :core_crate, {
2331
source: 'thirdparty/libcore/lib.rs'.in_root,
@@ -29,7 +37,7 @@ compile_rust :core_crate, {
2937
# zinc crate
3038
compile_rust :zinc_crate, {
3139
source: 'main.rs'.in_source,
32-
deps: :core_crate,
40+
deps: [:core_crate, :rlibc_crate],
3341
produce: 'main.rs'.in_source.as_rlib.in_build,
3442
out_dir: true,
3543
recompile_on: [:triple, :platform],
@@ -38,6 +46,7 @@ compile_rust :zinc_crate, {
3846
# zinc runtime support lib
3947
compile_rust :zinc_support, {
4048
source: 'lib/support.rs'.in_source,
49+
deps: [:rlibc_crate],
4150
produce: 'support.o'.in_intermediate,
4251
llvm_pass: :inline,
4352
lto: false,

src/lib/support.rs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,51 +17,6 @@
1717
#![crate_type="rlib"]
1818
#![feature(asm, intrinsics)]
1919

20-
extern "rust-intrinsic" {
21-
pub fn offset<T>(dst: *const T, offset: int) -> *const T;
22-
}
23-
24-
#[allow(non_camel_case_types)]
25-
pub type c_int = i32;
26-
27-
#[no_mangle]
28-
#[no_split_stack]
29-
#[inline(never)]
30-
pub fn memcpy(dest: *mut u8, src: *const u8, n: int) {
31-
unsafe {
32-
let mut i = 0;
33-
while i < n {
34-
*(offset(dest as *const u8, i) as *mut u8) = *(offset(src, i));
35-
i += 1;
36-
}
37-
}
38-
}
39-
40-
#[no_mangle]
41-
#[no_split_stack]
42-
pub extern "C" fn __aeabi_memcpy(dest: *mut u8, src: *const u8, n: int) {
43-
memcpy(dest, src, n);
44-
}
45-
46-
#[no_mangle]
47-
#[no_split_stack]
48-
#[inline(never)]
49-
pub fn memset(s: *mut u8, c: c_int, n: int) {
50-
unsafe {
51-
let mut i = 0;
52-
while i < n {
53-
*(offset(s as *const u8, i) as *mut u8) = c as u8;
54-
i += 1;
55-
}
56-
}
57-
}
58-
59-
#[no_mangle]
60-
#[no_split_stack]
61-
pub extern "C" fn __aeabi_memset(s: *mut u8, n: int, c: c_int) {
62-
memset(s, c, n);
63-
}
64-
6520
#[cfg(test)]
6621
#[no_split_stack]
6722
#[no_mangle]

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ STM32F403/407).
4545
*/
4646

4747
extern crate core;
48+
extern crate rlibc;
4849

4950
#[cfg(test)] #[phase(plugin,link)] extern crate std;
5051
#[cfg(test)] extern crate native;

support/rake.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ def provide_stdlibs
151151
sh "git clone --single-branch --depth 1 https://github.com/mozilla/rust #{t.name}"
152152
end.invoke
153153

154+
Rake::FileTask.define_task 'thirdparty/librlibc/lib.rs'.in_root do |t|
155+
sh "ln -s rust/src/librlibc thirdparty/librlibc"
156+
end.invoke
157+
154158
Rake::FileTask.define_task 'thirdparty/libcore/lib.rs'.in_root do |t|
155159
sh "ln -s rust/src/libcore thirdparty/libcore"
156160
end.invoke

0 commit comments

Comments
 (0)