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

Use rlibc crate #113

Merged
merged 1 commit into from
Jul 20, 2014
Merged

Use rlibc crate #113

merged 1 commit into from
Jul 20, 2014

Conversation

errordeveloper
Copy link
Member

No description provided.

@errordeveloper errordeveloper mentioned this pull request Jul 19, 2014
3 tasks
@errordeveloper
Copy link
Member Author

I'm wandering whether it will need llvm_pass: :inline, lto: false,..?

@farcaller
Copy link
Member

Ok, so this is a build dep, you still need to use extern crate in rust code.

@errordeveloper
Copy link
Member Author

Ok, so this is a build dep, you still need to use extern crate in rust code.

That's been added, as well :deps in the Rakefile, but I'm not 100% sure how that's being picked-up for linking...

@farcaller
Copy link
Member

It should go into src/main.rs, please try removing memory management code from libsupport and see if it still compiles.

@errordeveloper
Copy link
Member Author

@farcaller I see. What's up with all the __aeabi_* functions, were those needed for something specific?

@errordeveloper
Copy link
Member Author

@farcaller this worked:

diff --git a/src/lib/support.rs b/src/lib/support.rs
index 224910d..593c6a6 100644
--- a/src/lib/support.rs
+++ b/src/lib/support.rs
@@ -17,51 +17,6 @@
 #![crate_type="rlib"]
 #![feature(asm, intrinsics)]

-extern "rust-intrinsic" {
-  pub fn offset<T>(dst: *const T, offset: int) -> *const T;
-}
-
-#[allow(non_camel_case_types)]
-pub type c_int = i32;
-
-#[no_mangle]
-#[no_split_stack]
-#[inline(never)]
-pub fn memcpy(dest: *mut u8, src: *const u8, n: int) {
-  unsafe {
-    let mut i = 0;
-    while i < n {
-      *(offset(dest as *const u8, i) as *mut u8) = *(offset(src, i));
-      i += 1;
-    }
-  }
-}
-
-#[no_mangle]
-#[no_split_stack]
-pub extern "C" fn __aeabi_memcpy(dest: *mut u8, src: *const u8, n: int) {
-  memcpy(dest, src, n);
-}
-
-#[no_mangle]
-#[no_split_stack]
-#[inline(never)]
-pub fn memset(s: *mut u8, c: c_int, n: int) {
-  unsafe {
-    let mut i = 0;
-    while i < n {
-      *(offset(s as *const u8, i) as *mut u8) = c as u8;
-      i += 1;
-    }
-  }
-}
-
-#[no_mangle]
-#[no_split_stack]
-pub extern "C" fn __aeabi_memset(s: *mut u8, n: int, c: c_int) {
-  memset(s, c, n);
-}
-
 #[cfg(test)]
 #[no_split_stack]
 #[no_mangle]

...as far as rm -rf build/ ; rake PLATFORM=lpc17xx build_all test goes ;)

@errordeveloper errordeveloper changed the title Add dependency on rlibc crate Use rlibc crate Jul 19, 2014
@bharrisau
Copy link
Contributor

The aebi should be in compiler-intrinsic if I remember correctly.

@errordeveloper
Copy link
Member Author

The aebi should be in compiler-intrinsic if I remember correctly.

@bharrisau so we don't need to define those?

@errordeveloper
Copy link
Member Author

I have just grepped for either of these functions and none are called from anywhere apart from memcpy, but I'm not sure why it's in an extern block? Should that be called as rlibc::memcpy?

> git grep -n -p memcpy
src/os/debug.rs=24=extern {
src/os/debug.rs:25:  fn memcpy(dest: *mut u8, src: *u8, n: int);
src/os/debug.rs=36=pub fn setup(conf: &UARTConf) {
src/os/debug.rs:46:    memcpy(dst_ptr, src_ptr, size_of::<UART>() as int);

@bharrisau
Copy link
Contributor

We aren't using compiler-rt yet, so they need to be defined in support.

On 19 July 2014 19:42, Ilya Dmitrichenko notifications@github.com wrote:

I have just grepped for either of these functions and none are called from
anywhere apart from memcpy, but I'm not sure why it's in an extern block?
Should that be called as rlibc::memcpy?

git grep -n -p memcpy
src/os/debug.rs=24=extern {
src/os/debug.rs:25: fn memcpy(dest: *mut u8, src: *u8, n: int);
src/os/debug.rs=36=pub fn setup(conf: &UARTConf) {
src/os/debug.rs:46: memcpy(dst_ptr, src_ptr, size_of::() as int);


Reply to this email directly or view it on GitHub
#113 (comment).

@farcaller
Copy link
Member

__aeabi_memset was the actual function name, as generated by LLVM (which was a trivial trampoline to memset). So, if it's green without it — it's fine.

@errordeveloper
Copy link
Member Author

I have just grepped for either of these functions and none are called from anywhere apart from memcpy, but I'm not sure why it's in an extern block? Should that be called as rlibc::memcpy?

@farcaller @bharrisau any thoughts on that?

@farcaller
Copy link
Member

The debug code is special case, leave it as is (it's going away anyways).

@errordeveloper
Copy link
Member Author

Do I need to add anything here or, perhaps, test?

hacknbot added a commit that referenced this pull request Jul 20, 2014
Use rlibc crate

Reviewed-by: farcaller
@hacknbot hacknbot merged commit 393a230 into hackndev:master Jul 20, 2014
@errordeveloper errordeveloper deleted the rlibc branch July 20, 2014 09:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants