-
-
Save nbdd0121/d4bf7dd7f9b6d6b50fa18b1092f45a3c to your computer and use it in GitHub Desktop.
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
extern crate b; | |
extern "C" { | |
fn foo() -> i32; | |
} | |
#[no_mangle] | |
pub extern "C" fn main() -> i32 { | |
unsafe { foo() + b::bar() } | |
} |
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
extern "C" { | |
fn foo() -> i32; | |
} | |
pub fn bar() -> i32 { | |
unsafe { foo() } | |
} | |
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
extern inline int foo() { | |
return 1; | |
} |
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
#!/usr/bin/env bash | |
clang -S helper.c -emit-llvm -o helper.ll -O2 | |
sed -i 's/^define dso_local/define linkonce_odr dso_local/g' helper.ll | |
llvm-as helper.ll -o helper.bc | |
rustc +stage1 --crate-type=lib --emit=llvm-bc --emit=metadata b.rs -C opt-level=2 -L . | |
rustc +stage1 --crate-type=lib --emit=llvm-bc --emit=metadata a.rs -C opt-level=2 -L . | |
llvm-link b.bc helper.bc -o b.m.bc | |
clang -c b.m.bc -o b.o -O2 | |
llvm-link a.bc helper.bc -o a.m.bc | |
clang -c a.m.bc -o a.o -O2 | |
clang a.o b.o -o final.o |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment