Skip to content

Instantly share code, notes, and snippets.

@lnmx
Created Jul 29, 2015
Embed
What would you like to do?
rs
// 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 {} }
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