@@ -1291,7 +1291,8 @@ impl Build {
1291
1291
self . compile_objects ( & objects) ?;
1292
1292
self . assemble ( lib_name, & dst. join ( gnu_lib_name) , & objects) ?;
1293
1293
1294
- if self . get_target ( ) ?. contains ( "msvc" ) {
1294
+ let target = self . get_target ( ) ?;
1295
+ if target. contains ( "msvc" ) {
1295
1296
let compiler = self . get_base_compiler ( ) ?;
1296
1297
let atlmfc_lib = compiler
1297
1298
. env ( )
@@ -1337,11 +1338,12 @@ impl Build {
1337
1338
. print_metadata ( & format_args ! ( "cargo:rustc-link-lib={}" , stdlib. display( ) ) ) ;
1338
1339
}
1339
1340
// Link c++ lib from WASI sysroot
1340
- if self . get_target ( ) ? . contains ( "wasi" ) {
1341
+ if Build :: is_wasi_target ( target . as_ref ( ) ) {
1341
1342
let wasi_sysroot = self . wasi_sysroot ( ) ?;
1342
1343
self . cargo_output . print_metadata ( & format_args ! (
1343
- "cargo:rustc-flags=-L {}/lib/wasm32-wasi -lstatic=c++ -lstatic=c++abi" ,
1344
- Path :: new( & wasi_sysroot) . display( )
1344
+ "cargo:rustc-flags=-L {}/lib/{} -lstatic=c++ -lstatic=c++abi" ,
1345
+ Path :: new( & wasi_sysroot) . display( ) ,
1346
+ target
1345
1347
) ) ;
1346
1348
}
1347
1349
}
@@ -1943,7 +1945,7 @@ impl Build {
1943
1945
cmd. push_cc_arg ( "-fno-plt" . into ( ) ) ;
1944
1946
}
1945
1947
}
1946
- if target == "wasm32-wasip1" {
1948
+ if Build :: is_wasi_target ( target) {
1947
1949
// WASI does not support exceptions yet.
1948
1950
// https://github.com/WebAssembly/exception-handling
1949
1951
cmd. push_cc_arg ( "-fno-exceptions" . into ( ) ) ;
@@ -2893,10 +2895,7 @@ impl Build {
2893
2895
autodetect_android_compiler ( target, & host, gnu, clang)
2894
2896
} else if target. contains ( "cloudabi" ) {
2895
2897
format ! ( "{}-{}" , target, traditional)
2896
- } else if target == "wasm32-wasi"
2897
- || target == "wasm32-unknown-wasi"
2898
- || target == "wasm32-unknown-unknown"
2899
- {
2898
+ } else if Build :: is_wasi_target ( target) {
2900
2899
if self . cpp {
2901
2900
"clang++" . to_string ( )
2902
2901
} else {
@@ -3940,6 +3939,16 @@ impl Build {
3940
3939
) )
3941
3940
}
3942
3941
}
3942
+ fn is_wasi_target ( target : & str ) -> bool {
3943
+ const TARGETS : [ & ' static str ; 5 ] = [
3944
+ "wasm32-wasi" ,
3945
+ "wasm32-wasip1" ,
3946
+ "wasm32-wasip1-threads" ,
3947
+ "wasm32-wasip2" ,
3948
+ "wasm32-wasi-threads" ,
3949
+ ] ;
3950
+ return TARGETS . contains ( & target) ;
3951
+ }
3943
3952
3944
3953
fn cuda_file_count ( & self ) -> usize {
3945
3954
self . files
0 commit comments