Skip to content

Commit 02bae20

Browse files
authored
Fix compilation for wasm: env WASI_SYSROOT should be optional
On ubuntu-latest github action runner, it used to work without the environment variable. Fixed #1109 #1113
1 parent bffb5c0 commit 02bae20

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/lib.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -1339,12 +1339,13 @@ impl Build {
13391339
}
13401340
// Link c++ lib from WASI sysroot
13411341
if Build::is_wasi_target(target.as_ref()) {
1342-
let wasi_sysroot = self.wasi_sysroot()?;
1343-
self.cargo_output.print_metadata(&format_args!(
1344-
"cargo:rustc-flags=-L {}/lib/{} -lstatic=c++ -lstatic=c++abi",
1345-
Path::new(&wasi_sysroot).display(),
1346-
target
1347-
));
1342+
if let Ok(wasi_sysroot) = self.wasi_sysroot() {
1343+
self.cargo_output.print_metadata(&format_args!(
1344+
"cargo:rustc-flags=-L {}/lib/{} -lstatic=c++ -lstatic=c++abi",
1345+
Path::new(&wasi_sysroot).display(),
1346+
target
1347+
));
1348+
}
13481349
}
13491350
}
13501351

@@ -1950,10 +1951,11 @@ impl Build {
19501951
// https://github.com/WebAssembly/exception-handling
19511952
cmd.push_cc_arg("-fno-exceptions".into());
19521953
// Link clang sysroot
1953-
let wasi_sysroot = self.wasi_sysroot()?;
1954-
cmd.push_cc_arg(
1955-
format!("--sysroot={}", Path::new(&wasi_sysroot).display()).into(),
1956-
);
1954+
if let Ok(wasi_sysroot) = self.wasi_sysroot() {
1955+
cmd.push_cc_arg(
1956+
format!("--sysroot={}", Path::new(&wasi_sysroot).display()).into(),
1957+
);
1958+
}
19571959
}
19581960
}
19591961
}

0 commit comments

Comments
 (0)