Skip to content

Instantly share code, notes, and snippets.

@lnmx
Created July 29, 2015 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lnmx/e7a74bacafb7e38b8355 to your computer and use it in GitHub Desktop.
Save lnmx/e7a74bacafb7e38b8355 to your computer and use it in GitHub Desktop.
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