@@ -428,6 +428,42 @@ impl Build {
428
428
configure. arg ( "-D__STDC_NO_ATOMICS__" ) ;
429
429
}
430
430
431
+ if target. contains ( "wasi" ) {
432
+ configure. args ( [
433
+ // Termios isn't available whatsoever on WASM/WASI so we disable that
434
+ // fatal error: 'termios.h' file not found
435
+ "no-ui-console" ,
436
+ // WASI doesn't support UNIX sockets so we preemptively disable it
437
+ "no-sock" ,
438
+ // WASI doesn't have a concept of syslog, so we disable it
439
+ // fatal error: 'syslog.h' file not found
440
+ "-DNO_SYSLOG" ,
441
+ // WASI doesn't support (p)threads. Disabling preemptively.
442
+ "no-threads" ,
443
+ // WASI/WASM aren't really friends with ASM, so we disable it as well.
444
+ "no-asm" ,
445
+ // Disables the AFALG engine (AFALG-ENGine)
446
+ // Since AFALG depends on `AF_ALG` support on the linux kernel side
447
+ // it makes sense that we can't use it.
448
+ "no-afalgeng" ,
449
+ "-DOPENSSL_NO_AFALGENG=1" ,
450
+ // wasm lacks signal support; to enable minimal signal emulation, compile with
451
+ // -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal
452
+ "-D_WASI_EMULATED_SIGNAL" ,
453
+ // WASI lacks process-associated clocks; to enable emulation of the `times` function using the wall
454
+ // clock, which isn't sensitive to whether the program is running or suspended, compile with
455
+ // -D_WASI_EMULATED_PROCESS_CLOCKS and link with -lwasi-emulated-process-clocks
456
+ "-D_WASI_EMULATED_PROCESS_CLOCKS" ,
457
+ // WASI lacks a true mmap; to enable minimal mmap emulation, compile
458
+ // with -D_WASI_EMULATED_MMAN and link with -lwasi-emulated-mman
459
+ "-D_WASI_EMULATED_MMAN" ,
460
+ // WASI lacks process identifiers; to enable emulation of the `getpid` function using a
461
+ // placeholder value, which doesn't reflect the host PID of the program, compile with
462
+ // -D_WASI_EMULATED_GETPID and link with -lwasi-emulated-getpid
463
+ "-D_WASI_EMULATED_GETPID" ,
464
+ ] ) ;
465
+ }
466
+
431
467
if target. contains ( "musl" ) {
432
468
// Hack around openssl/openssl#7207 for now
433
469
configure. arg ( "-DOPENSSL_NO_SECURE_MEMORY" ) ;
@@ -578,6 +614,11 @@ impl Artifacts {
578
614
println ! ( "cargo:lib={}" , self . lib_dir. display( ) ) ;
579
615
if self . target . contains ( "msvc" ) {
580
616
println ! ( "cargo:rustc-link-lib=user32" ) ;
617
+ } else if self . target == "wasm32-wasi" {
618
+ println ! ( "cargo:rustc-link-lib=wasi-emulated-signal" ) ;
619
+ println ! ( "cargo:rustc-link-lib=wasi-emulated-process-clocks" ) ;
620
+ println ! ( "cargo:rustc-link-lib=wasi-emulated-mman" ) ;
621
+ println ! ( "cargo:rustc-link-lib=wasi-emulated-getpid" ) ;
581
622
}
582
623
}
583
624
}
0 commit comments