@@ -423,6 +423,56 @@ impl Build {
423
423
configure. arg ( "-D__STDC_NO_ATOMICS__" ) ;
424
424
}
425
425
426
+ if target. contains ( "wasi" ) {
427
+ configure. args ( [
428
+ // Termios isn't available whatsoever on WASM/WASI so we disable that
429
+ // fatal error: 'termios.h' file not found
430
+ "no-ui-console" ,
431
+ // WASI doesn't support UNIX sockets so we preemptively disable it
432
+ "no-sock" ,
433
+ // WASI doesn't have a concept of syslog, so we disable it
434
+ // fatal error: 'syslog.h' file not found
435
+ "-DNO_SYSLOG" ,
436
+ // wasm lacks signal support; to enable minimal signal emulation, compile with
437
+ // -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal
438
+ "-D_WASI_EMULATED_SIGNAL" ,
439
+ // WASI lacks process-associated clocks; to enable emulation of the `times` function using the wall
440
+ // clock, which isn't sensitive to whether the program is running or suspended, compile with
441
+ // -D_WASI_EMULATED_PROCESS_CLOCKS and link with -lwasi-emulated-process-clocks
442
+ "-D_WASI_EMULATED_PROCESS_CLOCKS" ,
443
+ // WASI lacks a true mmap; to enable minimal mmap emulation, compile
444
+ // with -D_WASI_EMULATED_MMAN and link with -lwasi-emulated-mman
445
+ "-D_WASI_EMULATED_MMAN" ,
446
+ // WASI lacks process identifiers; to enable emulation of the `getpid` function using a
447
+ // placeholder value, which doesn't reflect the host PID of the program, compile with
448
+ // -D_WASI_EMULATED_GETPID and link with -lwasi-emulated-getpid
449
+ "-D_WASI_EMULATED_GETPID" ,
450
+ // ----------
451
+ // The following arguments are taken from:
452
+ // https://github.com/wapm-packages/OpenSSL/blob/master/build.sh#L21
453
+ // Since this is a successful and reliable source for configuring WASM/I builds.
454
+ // I will try to explain those to the best of my ability though.
455
+ // ----------
456
+ // WASI doesn't support (p)threads. Disabling preemptively.
457
+ "no-threads" ,
458
+ // WASI/WASM aren't really friends with ASM, so we disable it as well.
459
+ "no-asm" ,
460
+ // Disables the AFALG engine (AFALG-ENGine)
461
+ // Since AFALG depends on `AF_ALG` support on the linux kernel side
462
+ // it makes sense that we can't use it.
463
+ "no-afalgeng" ,
464
+ "-DOPENSSL_NO_AFALGENG=1" ,
465
+ // ? Do we really want to always build statically for wasm? I guess yes?
466
+ "static" ,
467
+ // No fork(1) support in WASI, so we disable it
468
+ "-DHAVE_FORK=0" ,
469
+ "-DOPENSSL_NO_SPEED=1" ,
470
+ "-DOPENSSL_SYS_NETWARE" ,
471
+ "-DSIG_DFL=0" ,
472
+ "-DSIG_IGN=0" ,
473
+ ] ) ;
474
+ }
475
+
426
476
if target. contains ( "musl" ) {
427
477
// Hack around openssl/openssl#7207 for now
428
478
configure. arg ( "-DOPENSSL_NO_SECURE_MEMORY" ) ;
0 commit comments