Created
July 29, 2015 17:54
-
-
Save lnmx/e7a74bacafb7e38b8355 to your computer and use it in GitHub Desktop.
rs
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
// enable features required for a "no stdlib" build | |
#![feature(no_std, core, lang_items)] | |
// generate a static library (.a) | |
#![crate_type="staticlib"] | |
// do not link libstd | |
#![no_std] | |
// link libcore | |
extern crate core; | |
// export `yotz` as C-callable | |
#[no_mangle] | |
pub extern fn yotz(a: i32) -> i32 { | |
a * 2 | |
} | |
// runtime support functions normally provided by libstd | |
#[lang = "stack_exhausted"] extern fn stack_exhausted() {} | |
#[lang = "eh_personality"] extern fn eh_personality() {} | |
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} } | |
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
RFLAGS= | |
RFLAGS+= --target=x86_64-unknown-linux-musl | |
RFLAGS+= -C lto -C opt-level=3 -C link-args=-s -C no-redzone=yes | |
libhello.a: hello.rs Makefile | |
rustc $(RFLAGS) hello.rs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment