-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ccinfo: when providing ccinfo, optionally include libstd and alloc
The new attribute on RustToolchain is the label of a target that provides __rust_realloc et al, which allows ld(1) to use the .rlib files directly without needing to involve rustc in the linking step. This means Rust and C++ can be mixed in a cc_binary freely without needing any staticlib-type crates, which avoids problems if you have a cc_binary -> rust_library -> cc_library -> rust_library situation.
- Loading branch information
Showing
7 changed files
with
178 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <stddef.h> | ||
#include <stdlib.h> | ||
|
||
void* __rdl_alloc(size_t, size_t); | ||
void __rdl_dealloc(void*); | ||
void* __rdl_realloc(void*, size_t, size_t, size_t); | ||
void* __rdl_alloc_zeroed(size_t, size_t); | ||
void* __attribute__((weak)) __rust_alloc(size_t a, size_t b) { | ||
return __rdl_alloc(a, b); | ||
} | ||
void __attribute__((weak)) __rust_dealloc(void* a) { | ||
__rdl_dealloc(a); | ||
} | ||
void* __attribute__((weak)) | ||
__rust_realloc(void* a, size_t b, size_t c, size_t d) { | ||
return __rdl_realloc(a, b, c, d); | ||
} | ||
void* __attribute__((weak)) __rust_alloc_zeroed(size_t a, size_t b) { | ||
return __rdl_alloc_zeroed(a, b); | ||
} | ||
|
||
void __rust_alloc_error_handler(void*whatever) { | ||
abort(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extern "C" { | ||
void hello_from_rust(); | ||
} | ||
|
||
int main(int argc, char** argv){ | ||
hello_from_rust(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[no_mangle] | ||
pub extern "C" fn hello_from_rust() { | ||
println!("hello from rust"); | ||
} |