summaryrefslogtreecommitdiffstats
path: root/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/build.rs')
-rw-r--r--tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/build.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/build.rs b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/build.rs
new file mode 100644
index 000000000..3a7aa1be8
--- /dev/null
+++ b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/build.rs
@@ -0,0 +1,30 @@
+fn main() {
+ cc::Build::new()
+ .file("foo.c")
+ .compile("foo_c");
+
+ cc::Build::new()
+ .file("foo_asm.s")
+ .compile("foo_asm");
+
+ cc::Build::new()
+ .cpp(true)
+ .cpp_set_stdlib(None)
+ .file("foo_cxx.cpp")
+ .compile("foo_cxx");
+
+ // When the cmake crate detects the clang compiler, it passes the
+ // "--target" argument to the linker which subsequently fails. The
+ // `CMAKE_C_COMPILER_FORCED` option makes sure that `cmake` does not
+ // tries to test the compiler. From version 3.6 the option
+ // `CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY` can be used
+ // https://cmake.org/cmake/help/v3.5/module/CMakeForceCompiler.html
+ let dst = cmake::Config::new("libcmake_foo")
+ .build_target("cmake_foo")
+ .define("CMAKE_C_COMPILER_FORCED", "1")
+ .define("CMAKE_CXX_COMPILER_FORCED", "1")
+ .define("CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY", "1")
+ .build();
+ println!("cargo:rustc-link-search=native={}/build/", dst.display());
+ println!("cargo:rustc-link-lib=static=cmake_foo");
+}