From 3abdccb3d618335ea1280fa6bcc0f0f0be74db26 Mon Sep 17 00:00:00 2001 From: Arshia Ghafoori Date: Tue, 2 Sep 2025 12:35:41 +0400 Subject: [PATCH 01/10] Fix built w.r.t. to new EH sysroot --- .github/workflows/release-dev.yaml | 2 +- ext/opcache/ZendAccelerator.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-dev.yaml b/.github/workflows/release-dev.yaml index 9bd797a89c4aa..661707f4869a6 100644 --- a/.github/workflows/release-dev.yaml +++ b/.github/workflows/release-dev.yaml @@ -1,4 +1,4 @@ -name: Release +name: Release to Dev on: push: diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index e748f79cec282..d648c040b403a 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -4692,6 +4692,7 @@ static int accel_finish_startup(void) return FAILURE; } +#ifndef __wasi__ pid = fork(); if (pid == -1) { zend_shared_alloc_unlock(); @@ -4731,6 +4732,14 @@ static int accel_finish_startup(void) return FAILURE; } } +#else + // Note: in WASIX, there is only one uid; it has "root" access to everything within the + // sandbox, but not the base OS, so it's OK to run everything with that user. That is to + // say, we shouldn't need to fork a new process here. + // It is also a fact that forking doesn't work under WASIX+EH anyway. + zend_accel_error(ACCEL_LOG_FATAL, "Preloading cannot fork to spawn a new process in WASIX"); + exit(1); +#endif } else { if (ZCG(accel_directives).preload_user && *ZCG(accel_directives).preload_user) { From 38686f392a1e2dae39916fe06064185a751ddf8f Mon Sep 17 00:00:00 2001 From: Zebreus Date: Mon, 2 Feb 2026 17:11:19 +0100 Subject: [PATCH 02/10] Remove custom sendmail implementation --- .github/workflows/release-dev.yaml | 3 - .github/workflows/release.yaml | 3 - .github/workflows/wasix-pr.yaml | 13 --- ext/standard/config.m4 | 9 --- ext/standard/mail.c | 122 +---------------------------- main/main.c | 2 - wasix-configure-eh.sh | 1 - wasix-configure.sh | 1 - wasix-execute-eh.sh | 5 -- wasix-execute.sh | 5 -- 10 files changed, 1 insertion(+), 163 deletions(-) diff --git a/.github/workflows/release-dev.yaml b/.github/workflows/release-dev.yaml index 661707f4869a6..f2b2f2901b988 100644 --- a/.github/workflows/release-dev.yaml +++ b/.github/workflows/release-dev.yaml @@ -35,9 +35,6 @@ jobs: build-and-test: uses: "./.github/workflows/wasix-pr.yaml" needs: version-check - secrets: - SENDMAIL_DEFAULT_USERNAME: ${{ secrets.SENDMAIL_DEFAULT_USERNAME }} - SENDMAIL_DEFAULT_PASSWORD: ${{ secrets.SENDMAIL_DEFAULT_PASSWORD }} release: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 66ddd30fe12c4..d01c8a376628f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -35,9 +35,6 @@ jobs: build-and-test: uses: "./.github/workflows/wasix-pr.yaml" needs: version-check - secrets: - SENDMAIL_DEFAULT_USERNAME: ${{ secrets.SENDMAIL_DEFAULT_USERNAME }} - SENDMAIL_DEFAULT_PASSWORD: ${{ secrets.SENDMAIL_DEFAULT_PASSWORD }} release: runs-on: ubuntu-latest diff --git a/.github/workflows/wasix-pr.yaml b/.github/workflows/wasix-pr.yaml index b1ff473675448..63eedd8a5b4f2 100644 --- a/.github/workflows/wasix-pr.yaml +++ b/.github/workflows/wasix-pr.yaml @@ -2,11 +2,6 @@ name: WASIX build and test on: workflow_call: - secrets: - SENDMAIL_DEFAULT_USERNAME: - required: true - SENDMAIL_DEFAULT_PASSWORD: - required: true pull_request: branches: - "*-wasix" @@ -88,9 +83,6 @@ jobs: /usr/lib/llvm-20/lib/clang/20/lib/wasm32-unknown-wasi/libclang_rt.builtins.a - name: Build - env: - SENDMAIL_DEFAULT_USERNAME: ${{ secrets.SENDMAIL_DEFAULT_USERNAME }} - SENDMAIL_DEFAULT_PASSWORD: ${{ secrets.SENDMAIL_DEFAULT_PASSWORD }} run: | export SYSROOT=$(pwd)/sysroot/wasix-sysroot-eh/sysroot export PHP_WASIX_DEPS=$(pwd)/php-wasix-deps @@ -101,11 +93,6 @@ jobs: uses: wasmerio/setup-wasmer@v3.1 - name: Run WASIX tests - env: - MAIL_USERNAME: ${{ secrets.SENDMAIL_DEFAULT_USERNAME }} - MAIL_PASSWORD: ${{ secrets.SENDMAIL_DEFAULT_PASSWORD }} - MAIL_HOST: smtp.mailgun.org - MAIL_PORT: 587 run: | cd php bash wasix-test-start-containers.sh diff --git a/ext/standard/config.m4 b/ext/standard/config.m4 index d46c4c364bdab..24f44882830d1 100644 --- a/ext/standard/config.m4 +++ b/ext/standard/config.m4 @@ -455,15 +455,6 @@ else AC_MSG_RESULT(no) fi -dnl -dnl Include libwasix_sendmail when building to WASIX -dnl -if test "$ac_cv_have_decl___wasi__" == "yes"; then - if test -n "$WASIX_SENDMAIL_LIBS"; then - PHP_EVAL_LIBLINE($WASIX_SENDMAIL_LIBS) - fi -fi - dnl dnl Whether to enable 64-bit long ints when building to WASIX; dnl wasm32 uses 32-bit pointers but supports 64-bit int operations. diff --git a/ext/standard/mail.c b/ext/standard/mail.c index 60e2a0f8a86d0..4299c10bc2e8e 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -370,21 +370,6 @@ static int php_mail_detect_multiple_crlf(const char *hdr) { return 0; } -// The Rust source for this function is in https://github.com/wasix-org/php-wasix-sendmail -// As for why the code is in rust, well, because it's much easier to have it there than in C. -#ifdef __wasi__ -int wasix_sendmail(const char *host, uint16_t port, const char* username, const char* password, char **error_message, - const char *headers, const char *subject, const char *mail_from, const char *mail_to, const char *data); -#endif - -#ifdef __wasi__ -#define NO_REPLY "no-reply@" -#define MAIL_USERNAME "MAIL_USERNAME" -#define MAIL_PASSWORD "MAIL_PASSWORD" -#define MAIL_HOST "MAIL_HOST" -#define MAIL_PORT "MAIL_PORT" -#define MAIL_FROM_ADDRESS "MAIL_FROM_ADDRESS" -#endif /* {{{ php_mail */ PHPAPI int php_mail(const char *to, const char *subject, const char *message, const char *headers, const char *extra_cmd) @@ -393,17 +378,7 @@ PHPAPI int php_mail(const char *to, const char *subject, const char *message, co int tsm_err; char *tsm_errmsg = NULL; #endif -#ifdef __wasi__ - int wasix_sendmail_result; - char *wasi_errmsg = NULL; - char *sendmail_from = NULL; - bool sendmail_from_alloc = false; - char *smtp = NULL; - char *username = NULL; - char *password = NULL; - int smtp_port; -#endif - FILE * sendmail; + FILE *sendmail; int ret; char *sendmail_path = INI_STR("sendmail_path"); char *sendmail_cmd = NULL; @@ -476,101 +451,6 @@ PHPAPI int php_mail(const char *to, const char *subject, const char *message, co MAIL_RET(0); } -#ifdef __wasi__ - // Always prioritize the INI settings over the environment variables - smtp = INI_STR("SMTP"); - if (!smtp) { - smtp = getenv(MAIL_HOST); - } - - username = INI_STR("sendmail_username"); - if (!username) { - username = getenv(MAIL_USERNAME); - } - - password = INI_STR("sendmail_password"); - if (!password) { - password = getenv(MAIL_PASSWORD); - } - - smtp_port = INI_INT("smtp_port"); - if (!smtp_port) { - char* port = getenv(MAIL_PORT); - if (port) { - smtp_port = atoi(port); - } - } - if (!smtp_port) { - smtp_port = 587; // Default SMTP port - } - - sendmail_from = INI_STR("sendmail_from"); - if (!sendmail_from) { - sendmail_from = getenv(MAIL_FROM_ADDRESS); - } - if (!sendmail_from) { - // Construct a from address from the host name - zval *server_array, *host; - - if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || - zend_is_auto_global(ZSTR_KNOWN(ZEND_STR_AUTOGLOBAL_SERVER))) && - (server_array = &PG(http_globals)[TRACK_VARS_SERVER]) && - (host = zend_hash_str_find(Z_ARRVAL_P(server_array), "HTTP_HOST", sizeof("HTTP_HOST") - 1)) && - Z_TYPE_P(host) == IS_STRING) - { - char* host_str = Z_STRVAL_P(host); - - // if the string has this format: - // - // host:port - // - // only copy the host part. if not, copy the whole string - char* colon_ptr = strchr(host_str, ':'); - size_t host_len = colon_ptr ? colon_ptr - host_str : strlen(host_str); - size_t sendmail_from_len = strlen(NO_REPLY) + host_len + 1; - - sendmail_from = malloc(sendmail_from_len); - - if (sendmail_from == NULL) { - fprintf(stderr, "Memory allocation failed\n"); - MAIL_RET(0); - } - - sendmail_from_alloc = true; - - strcpy(sendmail_from, NO_REPLY); - strncpy(sendmail_from + strlen(NO_REPLY), host_str, host_len); - sendmail_from[strlen(NO_REPLY) + host_len] = '\0'; - } - } - - if (!username || !password || !smtp || !sendmail_from) { - php_error(E_WARNING, "Username, password, or smtp server for mail not provided"); - MAIL_RET(0); - } - - wasix_sendmail_result = wasix_sendmail( - smtp, - smtp_port, - username, - password, - &wasi_errmsg, hdr, subject, sendmail_from, to, message); - - if (sendmail_from_alloc) - free(sendmail_from); - - if (wasix_sendmail_result == FAILURE) - { - if (wasi_errmsg) { - php_error(E_WARNING, "%s", wasi_errmsg); - // Error strings live in static data section of libwasix-sendmail.a, no need to free - } - MAIL_RET(0); - } else { - MAIL_RET(1); - } -#endif - if (!sendmail_path) { #ifdef PHP_WIN32 /* handle old style win smtp sending */ diff --git a/main/main.c b/main/main.c index bf5ae28aa53ad..c4fb6aade2f3e 100644 --- a/main/main.c +++ b/main/main.c @@ -741,8 +741,6 @@ PHP_INI_BEGIN() PHP_INI_ENTRY("memory_limit", "128M", PHP_INI_ALL, OnChangeMemoryLimit) PHP_INI_ENTRY("precision", "14", PHP_INI_ALL, OnSetPrecision) PHP_INI_ENTRY("sendmail_from", NULL, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("sendmail_username", NULL, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("sendmail_password", NULL, PHP_INI_ALL, NULL) PHP_INI_ENTRY("sendmail_path", DEFAULT_SENDMAIL_PATH, PHP_INI_SYSTEM, NULL) PHP_INI_ENTRY("mail.force_extra_parameters",NULL, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnChangeMailForceExtra) PHP_INI_ENTRY("disable_functions", "", PHP_INI_SYSTEM, NULL) diff --git a/wasix-configure-eh.sh b/wasix-configure-eh.sh index 9f81174cb502f..c6985a7aefb08 100755 --- a/wasix-configure-eh.sh +++ b/wasix-configure-eh.sh @@ -41,7 +41,6 @@ export \ ONIG_LIBS="-lonig" \ IM_IMAGEMAGICK_CFLAGS="-I$PHP_WASIX_DEPS/include/ImageMagick -DIM_MAGICKWAND_HEADER_STYLE_SEVEN -DMAGICKCORE_QUANTUM_DEPTH=16 -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_CHANNEL_MASK_DEPTH=32" \ IM_IMAGEMAGICK_LIBS="-lMagickCore-7.Q16HDRI -lMagickWand-7.Q16HDRI -ltiff" \ - WASIX_SENDMAIL_LIBS="-lwasix_sendmail" \ PHP_BUILD_SYSTEM="clang(WASIX+WasmEH)" \ PHP_EXTRA_INCLUDES="" \ PHP_IPV6="yes" \ diff --git a/wasix-configure.sh b/wasix-configure.sh index 6b8a86bc04f94..de472704e0e92 100755 --- a/wasix-configure.sh +++ b/wasix-configure.sh @@ -41,7 +41,6 @@ export \ ONIG_LIBS="-lonig" \ IM_IMAGEMAGICK_CFLAGS="-I$PHP_WASIX_DEPS/include/ImageMagick -DIM_MAGICKWAND_HEADER_STYLE_SEVEN -DMAGICKCORE_QUANTUM_DEPTH=16 -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_CHANNEL_MASK_DEPTH=32" \ IM_IMAGEMAGICK_LIBS="-lMagickCore-7.Q16HDRI -lMagickWand-7.Q16HDRI -ltiff" \ - WASIX_SENDMAIL_LIBS="-lwasix_sendmail" \ PHP_BUILD_SYSTEM="clang(WASIX)" \ PHP_EXTRA_INCLUDES="" \ PHP_IPV6="yes" \ diff --git a/wasix-execute-eh.sh b/wasix-execute-eh.sh index f2601847e4f82..7c260c77fac6b 100755 --- a/wasix-execute-eh.sh +++ b/wasix-execute-eh.sh @@ -15,11 +15,6 @@ wasmer run sapi/cli/php.wasm \ -- \ -S localhost:8080 \ -t /app \ - -d smtp_port=587 \ - -d SMTP=sandbox.smtp.mailtrap.io \ - -d sendmail_from=someone@example.com \ - -d sendmail_username=aaaaaaaaaaaaaa \ - -d sendmail_password=bbbbbbbbbbbbbb \ -d upload_max_filesize=128M \ -d post_max_size=128M \ -d max_input_vars=6144 \ diff --git a/wasix-execute.sh b/wasix-execute.sh index f1f4ab687f764..d2ea7ff7311ee 100755 --- a/wasix-execute.sh +++ b/wasix-execute.sh @@ -15,11 +15,6 @@ wasmer run sapi/cli/php.wasm \ -- \ -S localhost:8080 \ -t /app \ - -d smtp_port=587 \ - -d SMTP=sandbox.smtp.mailtrap.io \ - -d sendmail_from=someone@example.com \ - -d sendmail_username=aaaaaaaaaaaaaa \ - -d sendmail_password=bbbbbbbbbbbbbb \ -d upload_max_filesize=128M \ -d post_max_size=128M \ -d max_input_vars=6144 \ From 516a92b73880037009db876428976814ff06a5d4 Mon Sep 17 00:00:00 2001 From: Zebreus Date: Tue, 3 Feb 2026 11:46:26 +0100 Subject: [PATCH 03/10] Use sendmail webc --- wasix-configure-eh.sh | 3 ++- wasmer-32.toml | 2 ++ wasmer-64.toml | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wasix-configure-eh.sh b/wasix-configure-eh.sh index c6985a7aefb08..d48caa77ffee5 100755 --- a/wasix-configure-eh.sh +++ b/wasix-configure-eh.sh @@ -59,7 +59,8 @@ export \ -Wl,--export=__heap_base -Wl,--export=__stack_pointer -Wl,--export=__data_end -Wl,--export=__wasm_init_tls \ -Wl,--export=__wasm_signal -Wl,--export=__tls_size -Wl,--export=__tls_align -Wl,--export=__tls_base \ -lwasi-emulated-mman -flto -g -Wl,-z,stack-size=8388608 -Wl,--error-limit=0 -L$PHP_WASIX_DEPS/lib-eh -v \ - --no-wasm-opt -Wl,-mllvm,--wasm-enable-sjlj" + --no-wasm-opt -Wl,-mllvm,--wasm-enable-sjlj" \ + PROG_SENDMAIL="/usr/bin/sendmail" ./buildconf --force diff --git a/wasmer-32.toml b/wasmer-32.toml index b13b9c7f4b353..a4777a07c7abc 100644 --- a/wasmer-32.toml +++ b/wasmer-32.toml @@ -7,6 +7,8 @@ readme = 'README.md' # See more keys and definitions at https://docs.wasmer.io/registry/manifest [dependencies] +"wasmer/bash" = "=1.0.25" +"sendmail/sendmail" = "0.1.5" [[module]] name = 'php' diff --git a/wasmer-64.toml b/wasmer-64.toml index dd1edc7da86cf..727ce8533dcc5 100644 --- a/wasmer-64.toml +++ b/wasmer-64.toml @@ -7,6 +7,8 @@ readme = 'README.md' # See more keys and definitions at https://docs.wasmer.io/registry/manifest [dependencies] +"wasmer/bash" = "=1.0.25" +"sendmail/sendmail" = "0.1.5" [[module]] name = 'php' From e8e9e63b4fd993cfc2aaaa345a7791d5f7863193 Mon Sep 17 00:00:00 2001 From: Zebreus Date: Mon, 9 Feb 2026 16:38:49 +0100 Subject: [PATCH 04/10] Delete non-eh build scripts --- wasix-build.sh | 11 ------- wasix-configure.sh | 76 ---------------------------------------------- wasix-execute.sh | 22 -------------- 3 files changed, 109 deletions(-) delete mode 100755 wasix-build.sh delete mode 100755 wasix-configure.sh delete mode 100755 wasix-execute.sh diff --git a/wasix-build.sh b/wasix-build.sh deleted file mode 100755 index d9c824f98591e..0000000000000 --- a/wasix-build.sh +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env sh - -set -eou - -make -j16 - -wasm-opt -O3 \ - --strip-debug \ - --asyncify \ - --pass-arg=max-func-params@32 \ - sapi/cli/php -o sapi/cli/php.wasm diff --git a/wasix-configure.sh b/wasix-configure.sh deleted file mode 100755 index de472704e0e92..0000000000000 --- a/wasix-configure.sh +++ /dev/null @@ -1,76 +0,0 @@ -#! /usr/bin/env sh - -set -eu - -if [ -f Makefile ]; then - make clean -fi - -SYSROOT=${SYSROOT:-"/home/arshia/repos/wasmer/wasix-libc/sysroot32"} -PHP_WASIX_DEPS=${PHP_WASIX_DEPS:-"../php-wasix-deps"} - -export \ - CURL_CFLAGS="-I$PHP_WASIX_DEPS/include/curl" \ - CURL_LIBS="-lcurl -lcrypto -lssl" \ - ZLIB_CFLAGS="-I$PHP_WASIX_DEPS/include/zlib" \ - ZLIB_LIBS="-lz" \ - LIBXML_CFLAGS="-I$PHP_WASIX_DEPS/include/libxml2" \ - LIBXML_LIBS="-lxml2 -llzma" \ - SQLITE_CFLAGS="-I$PHP_WASIX_DEPS/include/sqlite" \ - SQLITE_LIBS="-lsqlite3" \ - OPENSSL_CFLAGS="-I$PHP_WASIX_DEPS/include/openssl" \ - OPENSSL_LIBS="-lssl -lcrypto" \ - ICONV_CFLAGS="-I$PHP_WASIX_DEPS/include/iconv" \ - ICONV_LIBS="-liconv -lcharset -licrt" \ - ICU_CFLAGS="-I$PHP_WASIX_DEPS/include/icu -std=c11 -DU_DISABLE_VERSION_SUFFIX -DU_DISABLE_RENAMING" \ - ICU_CXXFLAGS="-I$PHP_WASIX_DEPS/include/icu -std=c++17 -DU_DISABLE_VERSION_SUFFIX -DU_DISABLE_RENAMING" \ - ICU_LIBS="-licudata -licui18n -licuio -licutu -licuuc" \ - PNG_CFLAGS="-I$PHP_WASIX_DEPS/include/png" \ - PNG_LIBS="-lpng" \ - JPEG_CFLAGS="-I$PHP_WASIX_DEPS/include/jpeg" \ - JPEG_LIBS="-ljpeg" \ - FREETYPE2_CFLAGS="-I$PHP_WASIX_DEPS/include/freetype" \ - FREETYPE2_LIBS="-lfreetype" \ - WEBP_CFLAGS="-I$PHP_WASIX_DEPS/include/webp" \ - WEBP_LIBS="-lwebp -lsharpyuv" \ - LIBZIP_CFLAGS="-I$PHP_WASIX_DEPS/include/libzip" \ - LIBZIP_LIBS="-lzip" \ - LIBSODIUM_CFLAGS="-I$PHP_WASIX_DEPS/include/libsodium" \ - LIBSODIUM_LIBS="-lsodium" \ - ONIG_CFLAGS="-I$PHP_WASIX_DEPS/include/oniguruma" \ - ONIG_LIBS="-lonig" \ - IM_IMAGEMAGICK_CFLAGS="-I$PHP_WASIX_DEPS/include/ImageMagick -DIM_MAGICKWAND_HEADER_STYLE_SEVEN -DMAGICKCORE_QUANTUM_DEPTH=16 -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_CHANNEL_MASK_DEPTH=32" \ - IM_IMAGEMAGICK_LIBS="-lMagickCore-7.Q16HDRI -lMagickWand-7.Q16HDRI -ltiff" \ - PHP_BUILD_SYSTEM="clang(WASIX)" \ - PHP_EXTRA_INCLUDES="" \ - PHP_IPV6="yes" \ - RANLIB=llvm-ranlib-20 \ - AR=llvm-ar-20 \ - NM=llvm-nm-20 \ - CC="clang-20 --target=wasm32-wasi --sysroot=$SYSROOT" \ - CXX="clang++-20 --target=wasm32-wasi --sysroot=$SYSROOT" \ - CFLAGS="-matomics -mbulk-memory -mmutable-globals -pthread -mthread-model posix -ftls-model=local-exec \ - -fno-trapping-math -D_WASI_EMULATED_MMAN -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_PROCESS_CLOCKS \ - -g -flto -O2 -std=c11" \ - CXXFLAGS="-matomics -mbulk-memory -mmutable-globals -pthread -mthread-model posix -ftls-model=local-exec \ - -fno-trapping-math -D_WASI_EMULATED_MMAN -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_PROCESS_CLOCKS \ - -g -flto -fno-exceptions -O2 -std=c++17" \ - LIBS="-Wl,--shared-memory -Wl,--max-memory=4294967296 -Wl,--import-memory -Wl,--export-dynamic \ - -Wl,--export=__heap_base -Wl,--export=__stack_pointer -Wl,--export=__data_end -Wl,--export=__wasm_init_tls \ - -Wl,--export=__wasm_signal -Wl,--export=__tls_size -Wl,--export=__tls_align -Wl,--export=__tls_base \ - -lwasi-emulated-mman -flto -g -Wl,-z,stack-size=8388608 -Wl,--error-limit=0 -L$PHP_WASIX_DEPS/lib -v \ - --no-wasm-opt" - -./buildconf --force - -./configure --enable-fd-setsize=8192 --enable-static --disable-shared --host=wasm32-wasi --target=wasm32-wasi \ - --enable-opcache --disable-opcache-jit --disable-huge-code-pages --disable-rpath --disable-cgi --with-zlib \ - --with-openssl --enable-mbstring --enable-mbregex --disable-zend-signals --prefix=/usr/bin \ - --with-valgrind=no --with-pcre-jit=no --with-iconv --disable-huge-code-pages --disable-phpdbg \ - --enable-bcmath --enable-tidy --enable-gd --enable-exif --with-jpeg --with-freetype --with-webp \ - --enable-fiber-asm --with-curl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zip --with-sodium \ - --with-pgsql=$PHP_WASIX_DEPS/pgsql --with-pdo-pgsql=$PHP_WASIX_DEPS/pgsql --enable-intl \ - --with-pdo-sqlite --enable-ftp --enable-igbinary --with-imagick=$PHP_WASIX_DEPS/ImageMagick \ - --program-suffix=".wasm" - -./wasix-build.sh diff --git a/wasix-execute.sh b/wasix-execute.sh deleted file mode 100755 index d2ea7ff7311ee..0000000000000 --- a/wasix-execute.sh +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/env sh - -set -eo - -wasmer run sapi/cli/php.wasm \ - --singlepass \ - --net \ - --mapdir /app:../wordpress \ - --mapdir /etc/ssl:../php-wasix-deps/openssl/ssl \ - --mapdir /icu:../php-wasix-deps/icu \ - --env SSL_CERT_DIR=/etc/ssl/certs \ - --use amin/bash \ - --forward-host-env \ - --env PHP_CLI_SERVER_WORKERS=3 \ - -- \ - -S localhost:8080 \ - -t /app \ - -d upload_max_filesize=128M \ - -d post_max_size=128M \ - -d max_input_vars=6144 \ - -d memory_limit=512M - From 2d7a190f27d5eeba7976084065bd7a65dc9e54aa Mon Sep 17 00:00:00 2001 From: Zebreus Date: Tue, 3 Feb 2026 12:44:29 +0100 Subject: [PATCH 05/10] Use wasixcc --- build/php.m4 | 2 +- wasix-configure-eh.sh | 31 ++++++++++++------------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/build/php.m4 b/build/php.m4 index 261aac2126076..5a06d372e4bec 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -742,7 +742,7 @@ AC_DEFUN([PHP_REQUIRE_CXX],[ if test -z "$php_cxx_done"; then AC_PROG_CXX AC_PROG_CXXCPP - PHP_ADD_LIBRARY(stdc++) + PHP_ADD_LIBRARY(c++) php_cxx_done=yes fi ]) diff --git a/wasix-configure-eh.sh b/wasix-configure-eh.sh index d48caa77ffee5..b008a65c5fc55 100755 --- a/wasix-configure-eh.sh +++ b/wasix-configure-eh.sh @@ -6,7 +6,6 @@ if [ -f Makefile ]; then make clean fi -SYSROOT=${SYSROOT:-"/home/arshia/repos/wasmer/wasix-libc/sysroot32-eh"} PHP_WASIX_DEPS=${PHP_WASIX_DEPS:-"../php-wasix-deps"} export \ @@ -44,22 +43,16 @@ export \ PHP_BUILD_SYSTEM="clang(WASIX+WasmEH)" \ PHP_EXTRA_INCLUDES="" \ PHP_IPV6="yes" \ - RANLIB=llvm-ranlib-20 \ - AR=llvm-ar-20 \ - NM=llvm-nm-20 \ - CC="clang-20 --target=wasm32-wasi --sysroot=$SYSROOT" \ - CXX="clang++-20 --target=wasm32-wasi --sysroot=$SYSROOT" \ - CFLAGS="-matomics -mbulk-memory -mmutable-globals -pthread -mthread-model posix -ftls-model=local-exec \ - -fno-trapping-math -D_WASI_EMULATED_MMAN -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_PROCESS_CLOCKS \ - -g -flto -O2 -fwasm-exceptions" \ - CXXFLAGS="-matomics -mbulk-memory -mmutable-globals -pthread -mthread-model posix -ftls-model=local-exec \ - -fno-trapping-math -D_WASI_EMULATED_MMAN -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_PROCESS_CLOCKS \ - -g -flto -fno-exceptions -O2 -fwasm-exceptions" \ - LIBS="-Wl,--shared-memory -Wl,--max-memory=4294967296 -Wl,--import-memory -Wl,--export-dynamic \ - -Wl,--export=__heap_base -Wl,--export=__stack_pointer -Wl,--export=__data_end -Wl,--export=__wasm_init_tls \ - -Wl,--export=__wasm_signal -Wl,--export=__tls_size -Wl,--export=__tls_align -Wl,--export=__tls_base \ - -lwasi-emulated-mman -flto -g -Wl,-z,stack-size=8388608 -Wl,--error-limit=0 -L$PHP_WASIX_DEPS/lib-eh -v \ - --no-wasm-opt -Wl,-mllvm,--wasm-enable-sjlj" \ + RANLIB="wasixranlib" \ + AR="wasixar" \ + NM="wasixnm" \ + CC="wasixcc" \ + CXX="wasixcc++" \ + CFLAGS="-g -flto -O2" \ + CXXFLAGS="-g -flto -O2" \ + LIBS="-L$PHP_WASIX_DEPS/lib-eh --no-wasm-opt" \ + WASIXCC_INCLUDE_CPP_SYMBOLS="yes" \ + WASIXCC_WASM_EXCEPTIONS="yes" \ PROG_SENDMAIL="/usr/bin/sendmail" ./buildconf --force @@ -70,8 +63,8 @@ export \ --with-valgrind=no --with-pcre-jit=no --with-iconv --disable-huge-code-pages --disable-phpdbg \ --enable-bcmath --enable-tidy --enable-gd --enable-exif --with-jpeg --with-freetype --with-webp \ --enable-fiber-asm --with-curl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zip --with-sodium \ - --with-pgsql=$PHP_WASIX_DEPS/pgsql-eh --with-pdo-pgsql=$PHP_WASIX_DEPS/pgsql-eh --enable-intl \ - --with-pdo-sqlite --enable-ftp --enable-igbinary --with-imagick \ + --with-pgsql="$PHP_WASIX_DEPS"/pgsql-eh --with-pdo-pgsql="$PHP_WASIX_DEPS"/pgsql-eh --enable-intl \ + --with-pdo-sqlite --enable-ftp --enable-igbinary --with-imagick --with-iconv="$PHP_WASIX_DEPS"/iconv-eh \ --program-suffix=".wasm" ./wasix-build-eh.sh From bfb63d1d9a5aa55361f43eee32e6ebb5c0b2a841 Mon Sep 17 00:00:00 2001 From: Zebreus Date: Tue, 3 Feb 2026 12:48:55 +0100 Subject: [PATCH 06/10] Install wasixcc in CI --- .github/workflows/wasix-pr.yaml | 174 +++++--------------------------- 1 file changed, 25 insertions(+), 149 deletions(-) diff --git a/.github/workflows/wasix-pr.yaml b/.github/workflows/wasix-pr.yaml index 63eedd8a5b4f2..f9b315dc2ba58 100644 --- a/.github/workflows/wasix-pr.yaml +++ b/.github/workflows/wasix-pr.yaml @@ -6,10 +6,16 @@ on: branches: - "*-wasix" +permissions: + contents: read + jobs: - build-and-test-32: - name: Build and Test - 32-bit + build-and-test: + name: Build and Test runs-on: ubuntu-latest + strategy: + matrix: + variant: ["32", "64"] steps: - name: Check out uses: actions/checkout@v3 @@ -27,140 +33,33 @@ jobs: - name: OS Setup (Ubuntu) run: | sudo apt-get update - sudo apt-get install -y build-essential wabt re2c + sudo apt-get install -y build-essential wabt re2c curl xz-utils tar npm i -g pnpm concurrently - wget https://apt.llvm.org/llvm.sh - chmod +x llvm.sh - sudo ./llvm.sh 20 - wget https://github.com/WebAssembly/binaryen/releases/download/version_123/binaryen-version_123-x86_64-linux.tar.gz tar -xzf binaryen-version_123-x86_64-linux.tar.gz sudo cp binaryen-version_123/bin/* /usr/bin/ - sudo rm -f /usr/bin/clang - sudo rm -f /usr/bin/clang++ - sudo ln -s /usr/bin/clang-20 /usr/bin/clang - sudo ln -s /usr/bin/clang++-20 /usr/bin/clang++ - sudo ln -s /usr/bin/llvm-ar-20 /usr/bin/llvm-ar - sudo ln -s /usr/bin/llvm-nm-20 /usr/bin/llvm-nm - sudo ln -s /usr/bin/llvm-ranlib-20 /usr/bin/llvm-ranlib - sudo ln -s /usr/bin/llvm-objdump-20 /usr/bin/llvm-objdump - - - name: Tool Versions - run: | - echo clang - clang -v - echo '####################' - echo llvm-ar - llvm-ar -V - echo '####################' - echo llvm-nm - llvm-nm -V - echo '####################' - echo llvm-ranlib - llvm-ranlib -V - echo '####################' - echo wasm-opt - wasm-opt --version - echo '####################' - echo wasm-strip - wasm-strip --version - - - name: Download wasix-libc - uses: dsaltares/fetch-gh-release-asset@1.1.2 - with: - repo: wasix-org/wasix-libc - file: sysroot-eh.tar.gz - target: sysroot/wasix-libc.tar.gz - - - name: Unpack wasix-libc - run: | - cd sysroot - tar xzf wasix-libc.tar.gz - sudo mkdir -p /usr/lib/llvm-20/lib/clang/20/lib/wasm32-unknown-wasi - sudo cp wasix-sysroot-eh/lib/wasm32-wasi/libclang_rt.builtins-wasm32.a \ - /usr/lib/llvm-20/lib/clang/20/lib/wasm32-unknown-wasi/libclang_rt.builtins.a - - - name: Build - run: | - export SYSROOT=$(pwd)/sysroot/wasix-sysroot-eh/sysroot - export PHP_WASIX_DEPS=$(pwd)/php-wasix-deps - cd php - bash wasix-configure-eh-32.sh || { cat config.log; exit -1; } - - - name: Setup Wasmer - uses: wasmerio/setup-wasmer@v3.1 - - - name: Run WASIX tests - run: | - cd php - bash wasix-test-start-containers.sh - conc --kill-others --success "command-1" \ - "bash wasix-test-server.sh" \ - "bash wasix-test-run.sh" - bash wasix-test-stop-containers.sh - echo All tests are passing! 🎉 - - - name: Archive build - uses: actions/upload-artifact@v4 - with: - name: php-wasix-32 - path: php/sapi/cli/php.wasm - - build-and-test-64: - name: Build and Test - 64-bit - runs-on: ubuntu-latest - steps: - - name: Check out - uses: actions/checkout@v3 + - name: Install wasixcc + uses: wasix-org/wasixcc@main with: - submodules: "recursive" - path: php - - - name: Check out php-wasix-deps - uses: actions/checkout@v3 - with: - repository: wasix-org/php-wasix-deps - submodules: "recursive" - path: php-wasix-deps - - - name: OS Setup (Ubuntu) - run: | - sudo apt-get update - sudo apt-get install -y build-essential wabt re2c - npm i -g pnpm concurrently - - wget https://github.com/WebAssembly/binaryen/releases/download/version_123/binaryen-version_123-x86_64-linux.tar.gz - tar -xzf binaryen-version_123-x86_64-linux.tar.gz - sudo cp binaryen-version_123/bin/* /usr/bin/ - - wget https://apt.llvm.org/llvm.sh - chmod +x llvm.sh - sudo ./llvm.sh 20 - - sudo rm -f /usr/bin/clang - sudo rm -f /usr/bin/clang++ - sudo ln -s /usr/bin/clang-20 /usr/bin/clang - sudo ln -s /usr/bin/clang++-20 /usr/bin/clang++ - sudo ln -s /usr/bin/llvm-ar-20 /usr/bin/llvm-ar - sudo ln -s /usr/bin/llvm-nm-20 /usr/bin/llvm-nm - sudo ln -s /usr/bin/llvm-ranlib-20 /usr/bin/llvm-ranlib - sudo ln -s /usr/bin/llvm-objdump-20 /usr/bin/llvm-objdump + github_token: ${{ secrets.GITHUB_TOKEN }} + sysroot-tag: v2026-02-16.1 + version: v0.3.0 - name: Tool Versions run: | - echo clang - clang -v + echo wasixcc + wasixcc -v echo '####################' - echo llvm-ar - llvm-ar -V + echo wasixar + wasixar -V echo '####################' - echo llvm-nm - llvm-nm -V + echo wasixnm + wasixnm -V echo '####################' - echo llvm-ranlib - llvm-ranlib -V + echo wasixranlib + wasixranlib -V echo '####################' echo wasm-opt wasm-opt --version @@ -168,40 +67,17 @@ jobs: echo wasm-strip wasm-strip --version - - name: Download wasix-libc - uses: dsaltares/fetch-gh-release-asset@1.1.2 - with: - repo: wasix-org/wasix-libc - file: sysroot-eh.tar.gz - target: sysroot/wasix-libc.tar.gz - - - name: Unpack wasix-libc - run: | - cd sysroot - tar xzf wasix-libc.tar.gz - sudo mkdir -p /usr/lib/llvm-20/lib/clang/20/lib/wasm32-unknown-wasi - sudo cp wasix-sysroot-eh/lib/wasm32-wasi/libclang_rt.builtins-wasm32.a \ - /usr/lib/llvm-20/lib/clang/20/lib/wasm32-unknown-wasi/libclang_rt.builtins.a - - name: Build - env: - SENDMAIL_DEFAULT_USERNAME: ${{ secrets.SENDMAIL_DEFAULT_USERNAME }} - SENDMAIL_DEFAULT_PASSWORD: ${{ secrets.SENDMAIL_DEFAULT_PASSWORD }} run: | export SYSROOT=$(pwd)/sysroot/wasix-sysroot-eh/sysroot export PHP_WASIX_DEPS=$(pwd)/php-wasix-deps cd php - bash wasix-configure-eh-64.sh || { cat config.log; exit -1; } + bash wasix-configure-eh-${{ matrix.variant }}.sh || { cat config.log; exit -1; } - name: Setup Wasmer uses: wasmerio/setup-wasmer@v3.1 - name: Run WASIX tests - env: - MAIL_USERNAME: ${{ secrets.SENDMAIL_DEFAULT_USERNAME }} - MAIL_PASSWORD: ${{ secrets.SENDMAIL_DEFAULT_PASSWORD }} - MAIL_HOST: smtp.mailgun.org - MAIL_PORT: 587 run: | cd php bash wasix-test-start-containers.sh @@ -214,5 +90,5 @@ jobs: - name: Archive build uses: actions/upload-artifact@v4 with: - name: php-wasix-64 - path: php/sapi/cli/php.wasm + name: php-wasix-${{ matrix.variant }} + path: php/sapi/cli/php.wasm \ No newline at end of file From 793f508529067ccb91bf3b5c82bcfbc5b807b483 Mon Sep 17 00:00:00 2001 From: Zebreus Date: Tue, 3 Feb 2026 13:32:21 +0100 Subject: [PATCH 07/10] Replace mapdir with volume --- wasix-execute-eh.sh | 6 +++--- wasix-test-server.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wasix-execute-eh.sh b/wasix-execute-eh.sh index 7c260c77fac6b..d66ca8fb706ca 100755 --- a/wasix-execute-eh.sh +++ b/wasix-execute-eh.sh @@ -5,9 +5,9 @@ set -eo wasmer run sapi/cli/php.wasm \ --llvm \ --net \ - --mapdir /app:../wordpress \ - --mapdir /etc/ssl:../php-wasix-deps/openssl/ssl \ - --mapdir /icu:../php-wasix-deps/icu \ + --volume ../wordpress:/app \ + --volume ../php-wasix-deps/openssl/ssl:/etc/ssl \ + --volume ../php-wasix-deps/icu:/icu \ --env SSL_CERT_DIR=/etc/ssl/certs \ --env OPENSSL_CONF=/etc/ssl/openssl.cnf \ --use amin/bash \ diff --git a/wasix-test-server.sh b/wasix-test-server.sh index df219d1d585de..e9b2775ce70a6 100755 --- a/wasix-test-server.sh +++ b/wasix-test-server.sh @@ -5,8 +5,8 @@ set -eux wasmer run ./sapi/cli/php.wasm \ --llvm \ --net \ - --mapdir /app:./wasix-tests \ - --mapdir /etc/ssl:../php-wasix-deps/openssl/ssl \ + --volume ./wasix-tests:/app \ + --volume ../php-wasix-deps/openssl/ssl:/etc/ssl \ --env MYSQL_HOST=localhost \ --env MYSQL_USERNAME=root \ --env MYSQL_PASSWORD=passwd \ From 9cd5222feae7c95af287cc86d97df28201615823 Mon Sep 17 00:00:00 2001 From: Zebreus Date: Thu, 19 Feb 2026 14:58:39 +0100 Subject: [PATCH 08/10] Fix exnref build and increase optimization levels --- .gitignore | 1 + wasix-build-eh.sh | 31 +++++++++++++++++++++++++++---- wasix-configure-eh.sh | 8 ++++---- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index cf172d5a86de8..5b3707d972f81 100644 --- a/.gitignore +++ b/.gitignore @@ -132,6 +132,7 @@ config.h.in /scripts/php-config /scripts/phpize php +php-debug.wasm php.wasm # ------------------------------------------------------------------------------ diff --git a/wasix-build-eh.sh b/wasix-build-eh.sh index 6f87f2b3161f3..d65d5acecfff9 100755 --- a/wasix-build-eh.sh +++ b/wasix-build-eh.sh @@ -4,13 +4,36 @@ set -eou make -j16 -wasm-opt -O3 \ - --emit-exnref \ +# Some wasm-opt passes are not compatible with EH. +# When generating debug info, we don't need to disable them but without debug info we do, otherwise wasm-opt crashes. +# The offending passes are flatten, dae-optimizing and inlining-optimizing. + +# First asyncify while preserving debug info +# O4 is only here for good measure, the important part is asyncify +wasm-opt -g \ + -O4 \ --no-validation \ --all-features \ - --strip-debug \ + --disable-gc \ + --closed-world \ + --skip-pass=flatten \ + --skip-pass=dae-optimizing \ + --skip-pass=inlining-optimizing \ --asyncify \ --pass-arg=asyncify-imports@wasix_32v1.proc_snapshot \ --pass-arg=asyncify-ignore-indirect \ --pass-arg=max-func-params@32 \ - sapi/cli/php -o sapi/cli/php.wasm \ No newline at end of file + sapi/cli/php -o sapi/cli/php-debug.wasm + +# A second wasm-opt run for stripping debug +# info and running full O4 +wasm-opt --strip-debug \ + -O4 \ + --no-validation \ + --all-features \ + --disable-gc \ + --closed-world \ + --skip-pass=flatten \ + --skip-pass=dae-optimizing \ + --skip-pass=inlining-optimizing \ + sapi/cli/php-debug.wasm -o sapi/cli/php.wasm \ No newline at end of file diff --git a/wasix-configure-eh.sh b/wasix-configure-eh.sh index b008a65c5fc55..7b912f287d999 100755 --- a/wasix-configure-eh.sh +++ b/wasix-configure-eh.sh @@ -48,9 +48,9 @@ export \ NM="wasixnm" \ CC="wasixcc" \ CXX="wasixcc++" \ - CFLAGS="-g -flto -O2" \ - CXXFLAGS="-g -flto -O2" \ - LIBS="-L$PHP_WASIX_DEPS/lib-eh --no-wasm-opt" \ + CFLAGS="-g -flto -O4" \ + CXXFLAGS="-g -flto -O4" \ + LIBS="-L$PHP_WASIX_DEPS/lib-eh --no-wasm-opt -g -flto -O4" \ WASIXCC_INCLUDE_CPP_SYMBOLS="yes" \ WASIXCC_WASM_EXCEPTIONS="yes" \ PROG_SENDMAIL="/usr/bin/sendmail" @@ -64,7 +64,7 @@ export \ --enable-bcmath --enable-tidy --enable-gd --enable-exif --with-jpeg --with-freetype --with-webp \ --enable-fiber-asm --with-curl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zip --with-sodium \ --with-pgsql="$PHP_WASIX_DEPS"/pgsql-eh --with-pdo-pgsql="$PHP_WASIX_DEPS"/pgsql-eh --enable-intl \ - --with-pdo-sqlite --enable-ftp --enable-igbinary --with-imagick --with-iconv="$PHP_WASIX_DEPS"/iconv-eh \ + --with-pdo-sqlite --enable-ftp --enable-igbinary --with-imagick --with-iconv="$PHP_WASIX_DEPS"/iconv-eh --enable-debug \ --program-suffix=".wasm" ./wasix-build-eh.sh From d7aa13eafc8243b5e06dabfc34865454769c1f4c Mon Sep 17 00:00:00 2001 From: Zebreus Date: Mon, 23 Feb 2026 12:50:00 +0100 Subject: [PATCH 09/10] Update wasixcc version to 0.4.0 --- .github/workflows/wasix-pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wasix-pr.yaml b/.github/workflows/wasix-pr.yaml index f9b315dc2ba58..c0428ca5ce612 100644 --- a/.github/workflows/wasix-pr.yaml +++ b/.github/workflows/wasix-pr.yaml @@ -45,7 +45,7 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} sysroot-tag: v2026-02-16.1 - version: v0.3.0 + version: v0.4.0 - name: Tool Versions run: | From 0982088538a7d406dcb9ec88483a9a3d39113e11 Mon Sep 17 00:00:00 2001 From: Zebreus Date: Mon, 23 Feb 2026 16:53:06 +0100 Subject: [PATCH 10/10] Update wasixcc version to 0.4.1 --- .github/workflows/wasix-pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wasix-pr.yaml b/.github/workflows/wasix-pr.yaml index c0428ca5ce612..97eeae1d74ae1 100644 --- a/.github/workflows/wasix-pr.yaml +++ b/.github/workflows/wasix-pr.yaml @@ -45,7 +45,7 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} sysroot-tag: v2026-02-16.1 - version: v0.4.0 + version: v0.4.1 - name: Tool Versions run: |