@@ -1291,7 +1291,8 @@ impl Build {
12911291 self . compile_objects ( & objects) ?;
12921292 self . assemble ( lib_name, & dst. join ( gnu_lib_name) , & objects) ?;
12931293
1294- if self . get_target ( ) ?. contains ( "msvc" ) {
1294+ let target = self . get_target ( ) ?;
1295+ if target. contains ( "msvc" ) {
12951296 let compiler = self . get_base_compiler ( ) ?;
12961297 let atlmfc_lib = compiler
12971298 . env ( )
@@ -1337,11 +1338,12 @@ impl Build {
13371338 . print_metadata ( & format_args ! ( "cargo:rustc-link-lib={}" , stdlib. display( ) ) ) ;
13381339 }
13391340 // Link c++ lib from WASI sysroot
1340- if self . get_target ( ) ? . contains ( "wasi" ) {
1341+ if Build :: is_wasi_target ( target . as_ref ( ) ) {
13411342 let wasi_sysroot = self . wasi_sysroot ( ) ?;
13421343 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
13451347 ) ) ;
13461348 }
13471349 }
@@ -1943,7 +1945,7 @@ impl Build {
19431945 cmd. push_cc_arg ( "-fno-plt" . into ( ) ) ;
19441946 }
19451947 }
1946- if target == "wasm32-wasip1" {
1948+ if Build :: is_wasi_target ( target) {
19471949 // WASI does not support exceptions yet.
19481950 // https://github.com/WebAssembly/exception-handling
19491951 cmd. push_cc_arg ( "-fno-exceptions" . into ( ) ) ;
@@ -2893,10 +2895,7 @@ impl Build {
28932895 autodetect_android_compiler ( target, & host, gnu, clang)
28942896 } else if target. contains ( "cloudabi" ) {
28952897 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) {
29002899 if self . cpp {
29012900 "clang++" . to_string ( )
29022901 } else {
@@ -3940,6 +3939,16 @@ impl Build {
39403939 ) )
39413940 }
39423941 }
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+ }
39433952
39443953 fn cuda_file_count ( & self ) -> usize {
39453954 self . files
0 commit comments