-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Curl extension for the Node.js build of PHP.wasm (#1273)
Ships the Node.js version of PHP built with `--with-libcurl` option to support the curl extension. It also changes two nuances in the overall PHP build process: * It replaces the `select(2)` function using `-Wl,--wrap=select` emcc option instead of patching PHP source code – this enables supporting asynchronous `select(2)` in curl without additional patches. * Brings the `__wrap_select` implementation more in line with `select(2)`, add support for `POLLERR`. * Adds support for polling file descriptors that represent neither child processes nor streams in `poll(2)` – that's because `libcurl` polls `/dev/urandom`. Builds on top of and supersedes #1133 ## Debugging Asyncify problems The [typical way of resolving Asyncify crashes](https://wordpress.github.io/wordpress-playground/architecture/wasm-asyncify/) didn't work during the work on this PR. Functions didn't come up in the error messages and even raw stack traces. The reasons are unclear. [The JSPI build of PHP](#1339) was more helpful as it enabled logging the current stack trace in all the asynchronous calls, which quickly revealed all the missing `ASYNCIFY_ONLY` functions. This is the way to debug any future issues until we fully migrate to JSPI. ## Testing Instructions Confirm the CI checks pass. This PR ships a few new tests specifically targeting networking with curl. ## Related resources * #85 * #1093 --------- Co-authored-by: Adam Zieliński <adam@adamziel.com> Co-authored-by: MHO <yannick@chillpills.io>
- Loading branch information
1 parent
cf118a4
commit 3fd0315
Showing
44 changed files
with
10,680 additions
and
2,470 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
FROM playground-php-wasm:base | ||
|
||
RUN mkdir -p /root/lib/include /root/lib/lib | ||
COPY ./libz/dist/root/lib/include /root/lib/include | ||
COPY ./libz/dist/root/lib/lib /root/lib/lib | ||
COPY ./libopenssl/dist/root/lib/include /root/lib/include | ||
COPY ./libopenssl/dist/root/lib/lib /root/lib/lib | ||
|
||
ARG CURL_VERSION="curl-7.69.1" | ||
|
||
RUN /root/copy-lib.sh lib-libz | ||
RUN set -euxo pipefail && \ | ||
source /root/emsdk/emsdk_env.sh && \ | ||
wget https://curl.haxx.se/download/$CURL_VERSION.tar.gz && \ | ||
tar xf $CURL_VERSION.tar.gz | ||
|
||
WORKDIR /root/$CURL_VERSION | ||
|
||
RUN CPPFLAGS="-I/root/lib/include " \ | ||
LDFLAGS="-L/root/lib/lib " \ | ||
PKG_CONFIG_PATH=$PKG_CONFIG_PATH \ | ||
source /root/emsdk/emsdk_env.sh && \ | ||
emconfigure ./configure \ | ||
--build i386-pc-linux-gnu \ | ||
--target wasm32-unknown-emscripten \ | ||
--prefix=/root/lib/ \ | ||
--disable-shared \ | ||
--enable-static \ | ||
--with-ssl \ | ||
--with-openssl=/root/lib \ | ||
--enable-https \ | ||
--enable-http \ | ||
--disable-pop3 \ | ||
--disable-imap \ | ||
--disable-smb \ | ||
--disable-smtp \ | ||
--disable-telnet \ | ||
--disable-gopher \ | ||
--disable-ftp \ | ||
--disable-ftps \ | ||
--disable-rtsp \ | ||
--disable-tftp \ | ||
--disable-pthreads \ | ||
--disable-threaded-resolver \ | ||
--with-zlib=/root/lib | ||
|
||
RUN cp /root/emsdk/upstream/bin/wasm-ld /root/emsdk/upstream/bin/wasm-ld-original && \ | ||
echo $'#!/bin/bash\n\ | ||
if [[ " $@ " =~ " -o curl " ]]; then \n\ | ||
echo '' > /root/curl-7.69.1/src/curl; \n\ | ||
echo '' > /root/curl-7.69.1/curl; \n\ | ||
fi; \n\ | ||
/root/emsdk/upstream/bin/wasm-ld-original "$@" || true; \n\ | ||
exit 0; \n' > /root/emsdk/upstream/bin/wasm-ld && \ | ||
chmod a+x /root/emsdk/upstream/bin/wasm-ld | ||
|
||
|
||
RUN source /root/emsdk/emsdk_env.sh && \ | ||
EMCC_SKIP="-lc -lz -lcurl -lssl " \ | ||
EMCC_FLAGS="-sSIDE_MODULE -Wl,--wrap=select " emmake make -i || true | ||
|
||
RUN source /root/emsdk/emsdk_env.sh && \ | ||
EMCC_SKIP="-lc -lz -lcurl -lssl " \ | ||
EMCC_FLAGS="-sSIDE_MODULE -Wl,--wrap=select " emmake make install -i || true | ||
|
||
RUN ls -R /root/lib |
Oops, something went wrong.