New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rlibc crate #113

Merged
merged 1 commit into from Jul 20, 2014

Conversation

Projects
None yet
4 participants
@errordeveloper
Member

errordeveloper commented Jul 19, 2014

No description provided.

@errordeveloper errordeveloper referenced this pull request Jul 19, 2014

Closed

Remove libsupport #106

2 of 3 tasks complete
@errordeveloper

This comment has been minimized.

Member

errordeveloper commented Jul 19, 2014

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

@farcaller

This comment has been minimized.

Member

farcaller commented Jul 19, 2014

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

@errordeveloper

This comment has been minimized.

Member

errordeveloper commented Jul 19, 2014

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

This comment has been minimized.

Member

farcaller commented Jul 19, 2014

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

@errordeveloper

This comment has been minimized.

Member

errordeveloper commented Jul 19, 2014

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

@errordeveloper

This comment has been minimized.

Member

errordeveloper commented Jul 19, 2014

@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 from Add dependency on rlibc crate to Use rlibc crate Jul 19, 2014

@bharrisau

This comment has been minimized.

Contributor

bharrisau commented Jul 19, 2014

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

@errordeveloper

This comment has been minimized.

Member

errordeveloper commented Jul 19, 2014

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

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

@errordeveloper

This comment has been minimized.

Member

errordeveloper commented Jul 19, 2014

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

This comment has been minimized.

Contributor

bharrisau commented Jul 19, 2014

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

This comment has been minimized.

Member

farcaller commented Jul 19, 2014

__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

This comment has been minimized.

Member

errordeveloper commented Jul 19, 2014

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

This comment has been minimized.

Member

farcaller commented Jul 19, 2014

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

@errordeveloper

This comment has been minimized.

Member

errordeveloper commented Jul 19, 2014

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

@farcaller

This comment has been minimized.

farcaller commented on 393a230 Jul 20, 2014

r+

@hacknbot

This comment has been minimized.

Contributor

hacknbot commented on 393a230 Jul 20, 2014

saw approval from farcaller
at errordeveloper@393a230

This comment has been minimized.

Contributor

hacknbot replied Jul 20, 2014

merging errordeveloper/zinc/rlibc = 393a230 into auto

This comment has been minimized.

Contributor

hacknbot replied Jul 20, 2014

errordeveloper/zinc/rlibc = 393a230 merged ok, testing candidate = 04e81fb

This comment has been minimized.

Contributor

hacknbot replied Jul 20, 2014

This comment has been minimized.

Contributor

hacknbot replied Jul 20, 2014

fast-forwarding master to auto = 04e81fb

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

Merge pull request #113 from errordeveloper/rlibc
Use rlibc crate

Reviewed-by: farcaller

@hacknbot hacknbot merged commit 393a230 into hackndev:master Jul 20, 2014

2 checks passed

continuous-integration/travis-ci The Travis CI build passed
Details
default all tests passed
Details

@errordeveloper errordeveloper deleted the errordeveloper:rlibc branch Jul 20, 2014

bors added a commit to rust-lang/rust that referenced this pull request Jul 21, 2014

auto merge of #15815 : errordeveloper/rust/rlibc_unit_tests, r=alexcr…
…ichton

We are pulling in rlibc into Zinc (hackndev/zinc#113), but while reading the code, I though it could do with some unit tests.

<strike>So I have added some tests here, but seem like there are a few issues... Please see comments with `XXX` and respond if you have any thoughts...</strike>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment