Skip to content

Commit fc60790

Browse files
committed
wasm3-sys: Compile with -fno-stack-protector on SGX
1 parent eb08659 commit fc60790

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

wasm3-sys/build.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,20 @@ fn main() {
106106
.extra_warnings(false)
107107
.include(WASM3_SOURCE);
108108

109+
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
110+
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap();
111+
let target_vendor = env::var("CARGO_CFG_TARGET_VENDOR").unwrap();
112+
113+
// Set options specific for x86_64-fortanix-unknown-sgx target.
114+
if target_arch == "x86_64" && target_env == "sgx" && target_vendor == "fortanix" {
115+
// Disable the stack protector as the Fortanix ABI currently sets FS and GS bases to the
116+
// same value and the stack protector assumes the canary value is at FS:0x28 but with the
117+
// Fortanix ABI that contains a copy of RSP.
118+
cfg.flag("-fno-stack-protector");
119+
}
120+
109121
// Add any extra arguments from the environment to the CC command line.
110-
if let Ok(extra_clang_args) = std::env::var("BINDGEN_EXTRA_CLANG_ARGS") {
122+
if let Ok(extra_clang_args) = env::var("BINDGEN_EXTRA_CLANG_ARGS") {
111123
// Try to parse it with shell quoting. If we fail, make it one single big argument.
112124
if let Some(strings) = shlex::split(&extra_clang_args) {
113125
strings.iter().for_each(|string| {

0 commit comments

Comments
 (0)