Skip to content

Commit bf9c3fa

Browse files
authored
[ php-wasm ] Add xdebug shared extension to @php-wasm/node JSPI (#2248)
1 parent 7ec3637 commit bf9c3fa

File tree

104 files changed

+448858
-46085
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+448858
-46085
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,37 @@ jobs:
3030
fail-fast: false
3131
matrix:
3232
include:
33-
- name: test-unit-asyncify (1/15)
33+
- name: test-unit-asyncify (1/16)
3434
target: test
35-
- name: test-unit-asyncify (2/15)
35+
- name: test-unit-asyncify (2/16)
3636
target: test-php
37-
- name: test-unit-asyncify (3/15)
37+
- name: test-unit-asyncify (3/16)
38+
target: test-php-networking
39+
- name: test-unit-asyncify (4/16)
3840
target: test-php-request-handler-files
39-
- name: test-unit-asyncify (4/15)
41+
- name: test-unit-asyncify (5/16)
4042
target: test-php-request-handler-requests
41-
- name: test-unit-asyncify (5/15)
43+
- name: test-unit-asyncify (6/16)
4244
target: test-php-asyncify-file-get-contents-http
43-
- name: test-unit-asyncify (6/15)
45+
- name: test-unit-asyncify (7/16)
4446
target: test-php-asyncify-file-get-contents-https
45-
- name: test-unit-asyncify (7/15)
47+
- name: test-unit-asyncify (8/16)
4648
target: test-php-asyncify-fopen-http
47-
- name: test-unit-asyncify (8/15)
49+
- name: test-unit-asyncify (9/16)
4850
target: test-php-asyncify-fopen-https
49-
- name: test-unit-asyncify (9/15)
51+
- name: test-unit-asyncify (10/16)
5052
target: test-php-asyncify-fsockopen-http
51-
- name: test-unit-asyncify (10/15)
53+
- name: test-unit-asyncify (11/16)
5254
target: test-php-asyncify-fsockopen-https
53-
- name: test-unit-asyncify (11/15)
55+
- name: test-unit-asyncify (12/16)
5456
target: test-php-asyncify-gethostbyname-http
55-
- name: test-unit-asyncify (12/15)
57+
- name: test-unit-asyncify (13/16)
5658
target: test-php-asyncify-gethostbyname-https
57-
- name: test-unit-asyncify (13/15)
59+
- name: test-unit-asyncify (14/16)
5860
target: test-php-asyncify-mysqli-http
59-
- name: test-unit-asyncify (14/15)
61+
- name: test-unit-asyncify (15/16)
6062
target: test-php-asyncify-mysqli-https
61-
- name: test-unit-sqlite3 (15/15)
63+
- name: test-unit-asyncify (16/16)
6264
target: test-php-asyncify-sqlite3
6365
name: ${{ matrix.name }}
6466
services:
@@ -88,6 +90,24 @@ jobs:
8890
MYSQL_DATABASE: test_db
8991
MYSQL_USER: user
9092
MYSQL_PASSWORD: password
93+
test-unit-jspi:
94+
runs-on: ubuntu-latest
95+
needs: [lint-and-typecheck]
96+
strategy:
97+
fail-fast: false
98+
matrix:
99+
include:
100+
- name: test-unit-jspi (1/1)
101+
target: test-php-dynamic-loading-jspi
102+
name: ${{ matrix.name }}
103+
steps:
104+
- uses: actions/checkout@v4
105+
with:
106+
submodules: true
107+
- uses: ./.github/actions/prepare-playground
108+
with:
109+
node-version: 23
110+
- run: node --expose-gc node_modules/nx/bin/nx affected --target=${{ matrix.target }}
91111
# Most of these tests pass locally but the process is crashing
92112
# on the CI runner.
93113
#

packages/php-wasm/compile/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ libintl/asyncify/dist/root/lib/lib/libintl.a: base-image
264264
docker cp $$(docker create playground-php-wasm:libintl):/root/lib/include ./libintl/asyncify/dist/root/lib
265265
docker cp $$(docker create playground-php-wasm:libintl):/root/lib/data/. ./libintl/
266266

267-
268267
libintl_jspi: libintl/jspi/dist/root/lib/lib/libintl.a
269268
libintl/jspi/dist/root/lib/lib/libintl.a: base-image
270269
mkdir -p ./libintl/jspi/dist/root/lib

packages/php-wasm/compile/base-image/Dockerfile

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ RUN chmod a+x /root/replace.sh
6767
COPY ./replace-across-lines.sh /root/replace-across-lines.sh
6868
RUN chmod a+x /root/replace-across-lines.sh
6969

70+
COPY ./emcc-for-php-wasm.sh /root/emcc-for-php-wasm.sh
71+
7072
# Patch emcc to allow skipping flags and passing additional flags using environment variables.
7173
#
7274
# We're compiling libraries statically using emscripten's -sSIDE_MODULE. It differs from the usual unix
@@ -85,17 +87,10 @@ RUN chmod a+x /root/replace-across-lines.sh
8587
# │ skip those flags when │ │ add these flags when │
8688
# │ calling emcc │ │ calling emcc │
8789
# └────────────────────────┘ └────────────────────────┘
88-
RUN cp /root/emsdk/upstream/emscripten/emcc /root/emsdk/upstream/emscripten/emcc2 && \
89-
cp /root/emsdk/upstream/emscripten/emcc.py /root/emsdk/upstream/emscripten/emcc2.py && \
90-
echo $'#!/bin/bash\n\
91-
for arg do shift\n\
92-
[[ " ${EMCC_SKIP[*]} " =~ " ${arg} " ]] && continue \n\
93-
set -- "$@" "$arg" \n\
94-
done\n\
95-
# Passing extra flags breaks the version check \n\
96-
if [[ "$@" == "-v" ]]; then\n\
97-
export EMCC_FLAGS=""\n\
98-
fi\n\
99-
/root/emsdk/upstream/emscripten/emcc2 "$@" $EMCC_FLAGS \n' > /root/emsdk/upstream/emscripten/emcc && \
90+
RUN <<EOF
91+
set -euo pipefail
92+
cp /root/emsdk/upstream/emscripten/emcc /root/emsdk/upstream/emscripten/emcc2
93+
cp /root/emsdk/upstream/emscripten/emcc.py /root/emsdk/upstream/emscripten/emcc2.py
94+
cp /root/emcc-for-php-wasm.sh /root/emsdk/upstream/emscripten/emcc
10095
chmod a+x /root/emsdk/upstream/emscripten/emcc
101-
96+
EOF
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
# Passing extra flags breaks the version check
6+
if [[ "$@" == "-v" ]]; then
7+
export EMCC_FLAGS=""
8+
fi
9+
10+
# Convert args to an array for filtering
11+
args=("${@}")
12+
13+
# Remove flags that we do not want to pass to emcc
14+
if [[ -n "${EMCC_SKIP:-}" ]]; then
15+
for ((i=0; i < ${#args[@]}; i++)); do
16+
if [[ " ${EMCC_SKIP[*]} " =~ " ${args[$i]} " ]]; then
17+
unset 'args[i]'
18+
fi
19+
done
20+
fi
21+
22+
# Remove duplicate library references to avoid linking errors.
23+
# Begin at end because we generally want dependencies to come last,
24+
# and if two things depend on a lib, we want the lib to come after both.
25+
declare -A seen_libs
26+
for ((i=${#args[@]} - 1; i >= 0; i--)); do
27+
# Skip empty args because array may be sparse
28+
[[ -z "${args[$i]:-}" ]] && continue
29+
30+
arg=${args[i]}
31+
if (
32+
[[ "$arg" =~ ^-l([a-z]|[A-Z]|[0-9]|[\-_])+$ ]] ||
33+
[[ "$arg" =~ (^|/)lib([a-z]|[A-Z]|[0-9]|[\-_])+\.a$ ]]
34+
); then
35+
if [[ -v seen_libs["$arg"] ]]; then
36+
unset 'args[i]'
37+
else
38+
seen_libs["$arg"]=1
39+
fi
40+
fi
41+
done
42+
43+
/root/emsdk/upstream/emscripten/emcc2 "${args[@]}" ${EMCC_FLAGS:-}

packages/php-wasm/compile/libintl/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ RUN set -euxo pipefail && \
3131
cd /root/icu/source && \
3232
mkdir -p /root/lib && \
3333
source /root/emsdk/emsdk_env.sh && \
34+
export CFLAGS="-fPIC" && \
35+
export CXXFLAGS="-fPIC" && \
3436
emconfigure ./configure \
3537
--build=i386-pc-linux-gnu \
3638
--target=wasm32-unknown-emscripten \
@@ -41,8 +43,8 @@ RUN set -euxo pipefail && \
4143
--disable-shared \
4244
--enable-static && \
4345
export JSPI_FLAGS=$(if [ "$JSPI" = "1" ]; then echo "-sSUPPORT_LONGJMP=wasm -fwasm-exceptions"; else echo ""; fi) && \
44-
EMCC_FLAGS=" -D__x86_64__ -sSIDE_MODULE $JSPI_FLAGS " emmake make -j"$(nproc)" && \
45-
EMCC_FLAGS=" -D__x86_64__ -sSIDE_MODULE $JSPI_FLAGS " emmake make install -i;
46+
EMCC_FLAGS=" -D__x86_64__ -fPIC -sSIDE_MODULE $JSPI_FLAGS " emmake make -j"$(nproc)" && \
47+
EMCC_FLAGS=" -D__x86_64__ -fPIC -sSIDE_MODULE $JSPI_FLAGS " emmake make install;
4648

4749

4850
RUN set -euxo pipefail && \

packages/php-wasm/compile/libintl/asyncify/dist/root/lib/lib/icu/74.2/pkgdata.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ SOBJ=so
44
A=a
55
LIBPREFIX=lib
66
LIB_EXT_ORDER=.74.2
7-
COMPILE=/root/emsdk/upstream/emscripten/emcc -ffunction-sections -fdata-sections -D_REENTRANT -DU_HAVE_ELF_H=1 -DU_HAVE_STRTOD_L=1 -DU_HAVE_XLOCALE_H=1 -DU_HAVE_STRING_VIEW=1 -DU_ATTRIBUTE_DEPRECATED= -O2 -std=c11 -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -c
7+
COMPILE=/root/emsdk/upstream/emscripten/emcc -ffunction-sections -fdata-sections -D_REENTRANT -DU_HAVE_ELF_H=1 -DU_HAVE_STRTOD_L=1 -DU_HAVE_XLOCALE_H=1 -DU_HAVE_STRING_VIEW=1 -DU_ATTRIBUTE_DEPRECATED= -fPIC -std=c11 -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -c
88
LIBFLAGS=-I/root/lib/include -DPIC -fPIC
9-
GENLIB=/root/emsdk/upstream/emscripten/emcc -O2 -std=c11 -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wl,--gc-sections -shared -Wl,-Bsymbolic
9+
GENLIB=/root/emsdk/upstream/emscripten/emcc -fPIC -std=c11 -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wl,--gc-sections -shared -Wl,-Bsymbolic
1010
LDICUDTFLAGS=-nodefaultlibs -nostdlib
1111
LD_SONAME=-Wl,-soname -Wl,
1212
RPATH_FLAGS=
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)