Skip to content

Instantly share code, notes, and snippets.

@nikhilm
Created September 4, 2019 19:50
Show Gist options
  • Save nikhilm/a72d89002553ecab4511fbe77df223cc to your computer and use it in GitHub Desktop.
Save nikhilm/a72d89002553ecab4511fbe77df223cc to your computer and use it in GitHub Desktop.
rustc staticlib bug
[package]
edition = "2018"
name = "hello_world"
version = "0.1.0"
[lib]
crate-type = ["staticlib"]
name = "hello_world"
[dependencies]
# Can be any crate really. Just needed something small.
bitflags = "1.1.0"
[profile.release]
lto = "thin"
#[macro_use]
extern crate bitflags;
bitflags! {
struct Flags: u32 {
const A = 0b00000001;
const B = 0b00000010;
const C = 0b00000100;
const ABC = Self::A.bits | Self::B.bits | Self::C.bits;
}
}
#[no_mangle]
pub extern "C" fn hello_world(x: usize) {
let e1 = Flags::A | Flags::C;
println!("oh hey there {} {:?}", x, Flags::empty());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment