Skip to content

Commit 9915b90

Browse files
committed
Recompile PHP.wasm web JSPI 8.3 with Intl extension
1 parent 9583447 commit 9915b90

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

packages/php-wasm/compile/php/Dockerfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ RUN if [ "$WITH_MYSQL" = "yes" ]; then \
344344
# Build the patched PHP
345345
WORKDIR /root/php-src
346346
RUN source /root/emsdk/emsdk_env.sh && \
347-
ICU_CFLAGS="-D__x86_64__ -fPIC -I/root/lib/include" \
348347
CURL_CFLAGS="-I/root/lib/include" \
349348
WEBP_LIBS="-L/root/lib/lib" \
350349
WEBP_CFLAGS="-I/root/lib/include" \
@@ -2117,14 +2116,20 @@ RUN set -euxo pipefail; \
21172116
export OPTIMIZATION_FLAGS="-O0"; \
21182117
fi; \
21192118
PLATFORM_SPECIFIC_ARGS=''; \
2119+
ENVIRONMENT="$EMSCRIPTEN_ENVIRONMENT"; \
21202120
if [ "$EMSCRIPTEN_ENVIRONMENT" = "node" ]; then \
21212121
PLATFORM_SPECIFIC_ARGS="$PLATFORM_SPECIFIC_ARGS -DPHP_WASM_FILE_LOCKING_SUPPORT=1"; \
2122-
PLATFORM_SPECIFIC_ARGS="$PLATFORM_SPECIFIC_ARGS --js-library /root/phpwasm-emscripten-library-dynamic-linking.js"; \
21232122
PLATFORM_SPECIFIC_ARGS="$PLATFORM_SPECIFIC_ARGS --js-library /root/phpwasm-emscripten-library-file-locking-for-node.js -Wl,--wrap=getpid"; \
2124-
PLATFORM_SPECIFIC_ARGS="$PLATFORM_SPECIFIC_ARGS -s MAIN_MODULE"; \
2123+
else \
2124+
# Prevents "document is not defined" errors in Web Workers when using MAIN_MODULE.
2125+
# By default, Emscripten assumes MAIN_MODULE runs only in a web environment,
2126+
# so it injects WebGL and other browser-only APIs. Explicitly adding "worker"
2127+
# ensures the runtime is compatible with Web Workers as well.
2128+
ENVIRONMENT="$EMSCRIPTEN_ENVIRONMENT,worker"; \
21252129
fi; \
21262130
emcc $OPTIMIZATION_FLAGS \
21272131
--js-library /root/phpwasm-emscripten-library.js \
2132+
--js-library /root/phpwasm-emscripten-library-dynamic-linking.js \
21282133
--js-library /root/phpwasm-emscripten-library-known-undefined-functions.js \
21292134
$PLATFORM_SPECIFIC_ARGS \
21302135
-I . \
@@ -2139,6 +2144,7 @@ RUN set -euxo pipefail; \
21392144
-lproxyfs.js \
21402145
$ASYNCIFY_FLAGS \
21412146
$(cat /root/.emcc-php-wasm-flags) \
2147+
-s MAIN_MODULE \
21422148
-s EXPORTED_FUNCTIONS="$EXPORTED_FUNCTIONS" \
21432149
-s WASM_BIGINT=1 \
21442150
-s MIN_NODE_VERSION=200900 \
@@ -2158,7 +2164,7 @@ RUN set -euxo pipefail; \
21582164
/root/proc_open.c \
21592165
/root/php_wasm.c \
21602166
$(cat /root/.emcc-php-wasm-sources) \
2161-
-s ENVIRONMENT=$EMSCRIPTEN_ENVIRONMENT \
2167+
-s ENVIRONMENT=$ENVIRONMENT \
21622168
-s FORCE_FILESYSTEM=1 \
21632169
-s EXPORT_NAME="'PHPLoader'"
21642170
# Emscripten complains it can't find some Asyncify functions
@@ -2247,7 +2253,7 @@ RUN set -euxo pipefail; \
22472253
# separate copies of the code. Instead, we use a dynamic computation of the
22482254
# environment, based on the `RuntimeName` variable, which is an argument to the
22492255
# wrapper function.
2250-
/root/replace.sh $'s/ENVIRONMENT_IS_([A-Z]+)\s*=\s*(true|false)/ENVIRONMENT_IS_$1=RuntimeName==="$1"/g' /root/output/php.js; \
2256+
/root/replace.sh $'s/ENVIRONMENT_IS_([A-Z]+)\s*=[^;]*;/ENVIRONMENT_IS_$1=RuntimeName==="$1";/g' /root/output/php.js; \
22512257
/root/replace.sh 's/var ENV\s*=\s*\{/var ENV = PHPLoader.ENV || {/g' /root/output/php.js; \
22522258
# Patch Emscripten exit status to include a stack trace
22532259
# Override Emscripten's default ExitStatus class which gets
10.2 MB
Binary file not shown.
22 Bytes
Binary file not shown.

packages/php-wasm/web/public/php/jspi/php_8_3.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)