started using cc crate

This commit is contained in:
Raoul Strackx 2020-03-26 13:57:37 +01:00
parent 6db05904f6
commit 0526e750cd
6 changed files with 30 additions and 5 deletions

View File

@ -0,0 +1,6 @@
CHECK: cc_plus_one_c
CHECK: lfence
CHECK: popq
CHECK-NEXT: popq [[REGISTER:%[a-z]+]]
CHECK-NEXT: lfence
CHECK-NEXT: jmpq *[[REGISTER]]

View File

@ -7,3 +7,6 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
[build-dependencies]
cc = "1.0"

View File

@ -0,0 +1,5 @@
fn main() {
cc::Build::new()
.file("foo.c")
.compile("foo");
}

View File

@ -0,0 +1,4 @@
int cc_plus_one_c(int *arg) {
return *arg + 1;
}

View File

@ -1,3 +1,11 @@
fn main() {
println!("Hello, world!");
extern {
fn cc_plus_one_c(arg : &u32) -> u32;
}
fn main() {
let value : u32 = 41;
unsafe{
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cc_plus_one_c(&value));
}
}

View File

@ -12,10 +12,8 @@ function build {
# HACK(eddyb) sets `RUSTC_BOOTSTRAP=1` so Cargo can accept nightly features.
# These come from the top-level Rust workspace, that this crate is not a
# member of, but Cargo tries to load the workspace `Cargo.toml` anyway.
env RUSTC_BOOTSTRAP=1 \
env RUSTC_BOOTSTRAP=1
cargo -v run --target $TARGET
env RUSTC_BOOTSTRAP=1 \
cargo -v run --target $TARGET --release
popd
popd
}
@ -40,3 +38,4 @@ build
#check "libunwind::Registers_x86_64::jumpto()" jumpto.checks
check "std::io::stdio::_print::h87f0c238421c45bc" print.checks
check cc_plus_one_c cc_plus_one_c.checks