-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[RFC] Add support for building to the wasm32-wasi target #10457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: apt | ||
inputs: | ||
wasi_sdk_version: | ||
default: 19 | ||
wasmtime_version: | ||
default: 5.0.0 | ||
binaryen_version: | ||
default: 111 | ||
runs: | ||
using: composite | ||
steps: | ||
- shell: bash | ||
run: | | ||
set -x | ||
sudo apt-get update | ||
sudo apt-get install \ | ||
php \ | ||
libtool-bin \ | ||
bison \ | ||
re2c \ | ||
tcl | ||
- shell: bash | ||
run: | | ||
set -x | ||
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${{ inputs.wasi_sdk_version }}/wasi-sdk_${{ inputs.wasi_sdk_version }}.0_amd64.deb | ||
sudo dpkg -i wasi-sdk_${{ inputs.wasi_sdk_version }}.0_amd64.deb | ||
- shell: bash | ||
run: | | ||
echo /opt/wasi-sdk/bin >> $GITHUB_PATH | ||
- shell: bash | ||
run: | | ||
set -x | ||
mkdir -p /opt/bin | ||
wget https://github.com/bytecodealliance/wasmtime/releases/download/v${{ inputs.wasmtime_version }}/wasmtime-v${{ inputs.wasmtime_version }}-x86_64-linux.tar.xz | ||
tar -xvf wasmtime-v${{ inputs.wasmtime_version }}-x86_64-linux.tar.xz | ||
mv wasmtime-v${{ inputs.wasmtime_version }}-x86_64-linux/wasmtime /opt/bin/ | ||
- shell: bash | ||
run: | | ||
set -x | ||
mkdir -p /opt/bin | ||
wget https://github.com/WebAssembly/binaryen/releases/download/version_${{ inputs.binaryen_version }}/binaryen-version_${{ inputs.binaryen_version }}-x86_64-linux.tar.gz | ||
tar -xvf binaryen-version_${{ inputs.binaryen_version }}-x86_64-linux.tar.gz --strip-components=2 -C /opt/bin binaryen-version_${{ inputs.binaryen_version }}/bin/wasm-opt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: ./configure | ||
inputs: | ||
configurationParameters: | ||
default: '' | ||
required: false | ||
runs: | ||
using: composite | ||
steps: | ||
- shell: bash | ||
run: | | ||
set -x | ||
./buildconf --force | ||
./configure \ | ||
--host=wasm32-wasi host_alias=wasm32-musl-wasi \ | ||
--target=wasm32-wasi target_alias=wasm32-musl-wasi \ | ||
--disable-all \ | ||
--disable-ctype \ | ||
--disable-dom \ | ||
--disable-fiber-asm \ | ||
--disable-fileinfo \ | ||
--disable-filter \ | ||
--disable-flatfile \ | ||
--disable-huge-code-pages \ | ||
--disable-inifile \ | ||
--disable-mbregex \ | ||
--disable-mysqlnd-compression-support \ | ||
--disable-opcache \ | ||
--disable-opcache-jit \ | ||
--disable-pdo \ | ||
--disable-phar \ | ||
--disable-posix \ | ||
--disable-session \ | ||
--disable-simplexml \ | ||
--disable-tokenizer \ | ||
--disable-xml \ | ||
--disable-xmlreader \ | ||
--disable-xmlwriter \ | ||
--disable-zend-signals \ | ||
--without-cdb \ | ||
--without-libxml \ | ||
--without-openssl \ | ||
--without-pcre-jit \ | ||
--without-pear \ | ||
--without-sqlite3 \ | ||
CFLAGS="-D_WASI_EMULATED_GETPID -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_PROCESS_CLOCKS" \ | ||
LDFLAGS="-lwasi-emulated-getpid -lwasi-emulated-signal -lwasi-emulated-process-clocks" \ | ||
${{ inputs.configurationParameters }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Optimize | ||
runs: | ||
using: composite | ||
steps: | ||
- shell: bash | ||
run: | | ||
set -x | ||
/opt/bin/wasm-opt -O sapi/cli/php -o sapi/cli/php.optimized | ||
- shell: bash | ||
run: | | ||
set -x | ||
/opt/bin/wasm-opt -O sapi/cgi/php-cgi -o sapi/cgi/php-cgi.optimized |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Test | ||
inputs: | ||
testArtifacts: | ||
default: null | ||
required: false | ||
runTestsParameters: | ||
default: '' | ||
required: false | ||
runs: | ||
using: composite | ||
steps: | ||
- shell: bash | ||
run: | | ||
cat <<-'EOF' > /opt/bin/wasmtime-run-cli.sh | ||
#!/bin/bash | ||
WASMTIME_BACKTRACE_DETAILS=1 /opt/bin/wasmtime run --mapdir /::/ "$PWD/sapi/cli/php.optimized" 2> /dev/null -- "$@" | ||
EOF | ||
chmod +x /opt/bin/wasmtime-run-cli.sh | ||
cat <<-'EOF' > /opt/bin/wasmtime-run-cgi.sh | ||
#!/bin/bash | ||
WASMTIME_BACKTRACE_DETAILS=1 /opt/bin/wasmtime run --mapdir /::/ "$PWD/sapi/cgi/php-cgi.optimized" 2> /dev/null -- "$@" | ||
EOF | ||
chmod +x /opt/bin/wasmtime-run-cgi.sh | ||
- shell: bash | ||
run: | | ||
set -x | ||
export SKIP_IO_CAPTURE_TESTS=1 | ||
export TEST_PHP_JUNIT=junit.out.xml | ||
export STACK_LIMIT_DEFAULTS_CHECK=1 | ||
export TEST_PHP_EXECUTABLE=/opt/bin/wasmtime-run-cli.sh | ||
export TEST_PHP_CGI_EXECUTABLE=/opt/bin/wasmtime-run-cgi.sh | ||
export TEST_PHPDBG_EXECUTABLE="" | ||
php run-tests.php -q ${{ inputs.runTestsParameters }} \ | ||
-j$(/usr/bin/nproc) \ | ||
-g FAIL,BORK,LEAK,XLEAK \ | ||
--no-progress \ | ||
--offline \ | ||
--show-diff \ | ||
--show-slow 1000 \ | ||
--set-timeout 120 | ||
- uses: actions/upload-artifact@v3 | ||
if: always() && inputs.testArtifacts != null | ||
with: | ||
name: ${{ github.job }}_${{ inputs.testArtifacts }} | ||
path: ${{ github.workspace }}/junit.out.xml | ||
retention-days: 5 |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -312,3 +312,37 @@ jobs: | |||||||||
${{ github.sha }} \ | ||||||||||
$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) \ | ||||||||||
> $GITHUB_STEP_SUMMARY | ||||||||||
WASM32_WASI: | ||||||||||
name: "WASM32_WASI_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}" | ||||||||||
Comment on lines
+315
to
+316
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
just to make the CI job name shorter/nicer... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would keep |
||||||||||
runs-on: ubuntu-20.04 | ||||||||||
env: | ||||||||||
CC: clang | ||||||||||
CXX: clang++ | ||||||||||
LD: wasm-ld | ||||||||||
AR: llvm-ar | ||||||||||
RANLIB: llvm-ranlib | ||||||||||
steps: | ||||||||||
- name: git checkout | ||||||||||
uses: actions/checkout@v3 | ||||||||||
- name: apt | ||||||||||
uses: ./.github/actions/apt-wasi | ||||||||||
- name: ./configure | ||||||||||
uses: ./.github/actions/configure-wasi | ||||||||||
with: | ||||||||||
configurationParameters: >- | ||||||||||
--${{ matrix.debug && 'enable' || 'disable' }}-debug | ||||||||||
--${{ matrix.zts && 'enable' || 'disable' }}-zts | ||||||||||
- name: make | ||||||||||
env: | ||||||||||
CFLAGS: "-D_WASI_EMULATED_GETPID -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_PROCESS_CLOCKS" | ||||||||||
LDFLAGS: "-lwasi-emulated-getpid -lwasi-emulated-signal -lwasi-emulated-process-clocks" | ||||||||||
run: make -j$(/usr/bin/nproc) cgi cli | ||||||||||
- name: Optimize | ||||||||||
uses: ./.github/actions/optimize-wasi | ||||||||||
# To be defined how to approach test coverage on this platform. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All core tests (tests that does not require any unsupported extension) must pass or they must be exluded if they are expected to fail ATM.
Fibers are core part of the PHP language since PHP 8.0 release. Can the support be added from the day zero? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Will exclude tests that don't apply on this platform in a next pass.
We should look into that. If it's a prerequisite for this patch to land, then yes. If it's fine to iterate I'd prefer so, to not block the whole patch on smaller specifics, given the patch is already somewhat big. |
||||||||||
# - name: Test | ||||||||||
# uses: ./.github/actions/test-wasi | ||||||||||
# with: | ||||||||||
# testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} | ||||||||||
# - name: Verify generated files are up to date | ||||||||||
# uses: ./.github/actions/verify-generated-files |
Uh oh!
There was an error while loading. Please reload this page.