File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ fn main() {
17
17
let compile_target_arch = env:: var ( "CARGO_CFG_TARGET_ARCH" ) . expect ( "CARGO_CFG_TARGET_ARCH" ) ;
18
18
let compile_target_os = env:: var ( "CARGO_CFG_TARGET_OS" ) . expect ( "CARGO_CFG_TARGET_OS" ) ;
19
19
let compile_target_env = env:: var ( "CARGO_CFG_TARGET_ENV" ) . expect ( "CARGO_CFG_TARGET_ENV" ) ;
20
+ let compile_target_feature = env:: var ( "CARGO_CFG_TARGET_FEATURE" ) ;
20
21
// Except for Emscripten target (which emulates POSIX environment), compile to Wasm via WASI SDK
21
22
// which is currently the only standalone provider of stdlib for compilation of C/C++ libraries.
22
23
if compile_target_arch. starts_with ( "wasm" ) && compile_target_os != "emscripten" {
@@ -26,7 +27,13 @@ fn main() {
26
27
"WASI SDK not found at {wasi_sdk}"
27
28
) ;
28
29
build. compiler ( format ! ( "{wasi_sdk}/bin/clang++" ) ) ;
29
- println ! ( "cargo:rustc-link-search={wasi_sdk}/share/wasi-sysroot/lib/wasm32-wasi" ) ;
30
+ let wasi_sysroot_lib = match compile_target_feature {
31
+ Ok ( compile_target_feature) if compile_target_feature. contains ( "atomics" ) => {
32
+ "wasm32-wasi-threads"
33
+ }
34
+ _ => "wasm32-wasi" ,
35
+ } ;
36
+ println ! ( "cargo:rustc-link-search={wasi_sdk}/share/wasi-sysroot/lib/{wasi_sysroot_lib}" ) ;
30
37
// Wasm exceptions are new and not yet supported by WASI SDK.
31
38
build. flag ( "-fno-exceptions" ) ;
32
39
// WASI SDK only has libc++ available.
Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ int32_t __imported_wasi_snapshot_preview1_fd_write(int32_t,
43
43
__builtin_unreachable ();
44
44
}
45
45
46
+ int32_t __imported_wasi_snapshot_preview1_sched_yield () {
47
+ return 0 ;
48
+ }
49
+
46
50
_Noreturn void __imported_wasi_snapshot_preview1_proc_exit (int32_t ) {
47
51
__builtin_unreachable ();
48
52
}
You can’t perform that action at this time.
0 commit comments