]> git.lizzy.rs Git - rust.git/commitdiff
started using cc crate
authorRaoul Strackx <raoul.strackx@fortanix.com>
Thu, 26 Mar 2020 12:57:37 +0000 (13:57 +0100)
committerRaoul Strackx <raoul.strackx@fortanix.com>
Fri, 25 Sep 2020 13:02:15 +0000 (15:02 +0200)
src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_c.checks [new file with mode: 0644]
src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/Cargo.toml
src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/build.rs [new file with mode: 0644]
src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/foo.c [new file with mode: 0644]
src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/src/main.rs
src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh

diff --git a/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_c.checks b/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_c.checks
new file mode 100644 (file)
index 0000000..b93b33a
--- /dev/null
@@ -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]]
index 723cd7c3cc23282257940bd5c0ba2c38a9abec55..da1b1e7f06c58ddf5c819fcbcf73eb9b5e549c3c 100644 (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"
diff --git a/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/build.rs b/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/build.rs
new file mode 100644 (file)
index 0000000..3ccb410
--- /dev/null
@@ -0,0 +1,5 @@
+fn main() {
+    cc::Build::new()
+        .file("foo.c")
+        .compile("foo");
+}
diff --git a/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/foo.c b/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/foo.c
new file mode 100644 (file)
index 0000000..bfe7757
--- /dev/null
@@ -0,0 +1,4 @@
+
+int cc_plus_one_c(int *arg) {
+    return *arg + 1;
+}
index e7a11a969c037e00a796aafeff6258501ec15e9a..25adef5f91714f659f0a7e5345f65b314dc7f479 100644 (file)
@@ -1,3 +1,11 @@
+extern {
+    fn cc_plus_one_c(arg : &u32) -> u32;
+}
+
 fn main() {
-    println!("Hello, world!");
+    let value : u32 = 41;
+    
+    unsafe{
+        println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cc_plus_one_c(&value));
+    }
 }
index 98e5284aadcbea0a452fce06beab92a0122ffa6a..ae95dd9dac0ee197212c4930f7fbfc1d2ffb2b5f 100644 (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