8000 Emscripten: Add wasm64 target by ktock · Pull Request #927 · libffi/libffi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Emscripten: Add wasm64 target #927

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 58 additions & 3 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
# "info" field, or in Makefile.envs:
# https://github.com/pyodide/pyodide/blob/main/Makefile.envs#L2
PYTHON_VERSION: 3.12.7
EMSCRIPTEN_VERSION: 3.1.58
EMSCRIPTEN_VERSION: 4.0.10
EM_CACHE_FOLDER: emsdk-cache

jobs:
Expand All @@ -39,6 +39,21 @@ jobs:
actions-cache-folder: ${{ env.EM_CACHE_FOLDER }}

test-dejagnu:
strategy:
matrix:
target:
- name: wasm32
host: wasm32
configureflags:
testflags:
- name: wasm64
host: wasm64
configureflags:
testflags: -sMEMORY64=1
- name: wasm64-2
host: wasm64
configureflags: WASM64_MEMORY64=2
testflags: -sMEMORY64=2
runs-on: ubuntu-24.04
needs: [setup-emsdk-cache]
steps:
Expand All @@ -62,11 +77,26 @@ jobs:
version: ${{ env.EMSCRIPTEN_VERSION }}
actions-cache-folder: ${{ env.EM_CACHE_FOLDER }}

- name: Setup node.js
uses: actions/setup-node@v4
with:
node-version: 24

# This step updates emsdk's configuration file ".emscripten" to point to
# nodejs installed in the previous step.
- name: Configure emsdk to use the installed node.js
run: sed -i -E 's|NODE_JS = .*|NODE_JS = '"'$(which node)'"'|g' ${EMSDK}/.emscripten

- name: Install dependencies
run: sudo apt-get install dejagnu libltdl-dev

- name: Run tests
run: testsuite/emscripten/node-tests.sh
env:
TARGET_HOST: ${{ matrix.target.host }}
EXTRA_CONFIGURE_FLAGS: ${{ matrix.target.configureflags }}
EXTRA_CFLAGS: ${{ matrix.target.testflags }}
EXTRA_TEST_LDFLAGS: ${{ matrix.target.testflags }}

- name: Install rlgl and run
run: |
Expand All @@ -77,6 +107,21 @@ jobs:
exit $?

build:
strategy:
matrix:
target:
- name: wasm32
host: wasm32
configureflags:
testflags:
- name: wasm64
host: wasm64
configureflags:
testflags: -sMEMORY64=1
- name: wasm64-2
host: wasm64
configureflags: WASM64_MEMORY64=2
testflags: -sMEMORY64=2
runs-on: ubuntu-24.04
needs: [setup-emsdk-cache]
steps:
Expand All @@ -100,23 +145,33 @@ jobs:

- name: Build
run: ./testsuite/emscripten/build.sh
env:
TARGET_HOST: ${{ matrix.target.host }}
EXTRA_CONFIGURE_FLAGS: ${{ matrix.target.configureflags }}

- name: Build tests
run: |
cp -r testsuite/libffi.call testsuite/libffi.call.test
cp -r testsuite/libffi.closures testsuite/libffi.closures.test
./testsuite/emscripten/build-tests.sh testsuite/libffi.call.test
./testsuite/emscripten/build-tests.sh testsuite/libffi.closures.test
env:
EXTRA_CFLAGS: ${{ matrix.target.testflags }}
EXTRA_LD_FLAGS: ${{ matrix.target.testflags }}

- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: built-tests
name: built-tests-${{ matrix.target.name }}
path: ./testsuite/libffi.c*/

test:
strategy:
matrix:
target:
- name: wasm32
- name: wasm64
- name: wasm64-2
browser: ["chrome"]
# FIXME: selenium can't find gecko driver for "firefox"
runs-on: ubuntu-24.04
Expand All @@ -128,7 +183,7 @@ jobs:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: built-tests
name: built-tests-${{ matrix.target.name }}
path: ./testsuite/

- uses: conda-incubator/setup-miniconda@v3
Expand Down
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ noinst_HEADERS = src/aarch64/ffitarget.h src/aarch64/internal.h \
src/s390/ffitarget.h src/s390/internal.h src/sh/ffitarget.h \
src/sh64/ffitarget.h src/sparc/ffitarget.h \
src/sparc/internal.h src/tile/ffitarget.h src/ 8000 vax/ffitarget.h \
src/wasm32/ffitarget.h \
src/wasm/ffitarget.h \
src/x86/ffitarget.h src/x86/internal.h src/x86/internal64.h \
src/x86/asmnames.h src/xtensa/ffitarget.h src/dlmalloc.c \
src/kvx/ffitarget.h src/kvx/asm.h \
Expand Down Expand Up @@ -98,7 +98,7 @@ EXTRA_libffi_la_SOURCES = src/aarch64/ffi.c src/aarch64/sysv.S \
src/sh64/sysv.S src/sparc/ffi.c src/sparc/ffi64.c \
src/sparc/v8.S src/sparc/v9.S src/tile/ffi.c src/tile/tile.S \
src/vax/ffi.c src/vax/elfbsd.S src/x86/ffi.c src/x86/sysv.S \
src/wasm32/ffi.c \
src/wasm/ffi.c \
src/x86/ffiw64.c src/x86/win64.S src/x86/ffi64.c \
src/x86/unix64.S src/x86/sysv_intel.S src/x86/win64_intel.S \
src/xtensa/ffi.c src/xtensa/sysv.S src/kvx/ffi.c \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ tested:
| TILE-Gx/TILEPro | Linux | GCC |
| VAX | OpenBSD/vax | GCC |
| WASM32 | Emscripten | EMCC |
| WASM64 | Emscripten | EMCC |
| X86 | FreeBSD | GCC |
| X86 | GNU HURD | GCC |
| X86 | Interix | GCC |
Expand Down
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ AC_C_BIGENDIAN

GCC_AS_CFI_PSEUDO_OP

AC_ARG_VAR([WASM64_MEMORY64], [Used only for the wasm64 target. Set to 1 (default) or 2 for Emscripten's -sMEMORY64 mode])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between these?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user can use WASM64_MEMORY64 to control Emscripten's -sMEMORY64 flag. Both values 1 and 2 enable 64bit pointers for clang/lld. Emscripten's -sMEMORY64=2 additionally lowers the output to wasm32 in Binaryen so it runs on engines that don't support wasm64.


case "$TARGET" in
SPARC)
AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
Expand Down Expand Up @@ -182,6 +184,12 @@ case "$TARGET" in
[Define if the compiler uses zarch features.])
fi
;;
wasm64)
if test -z "$WASM64_MEMORY64"; then
WASM64_MEMORY64=1
fi
CFLAGS="$CFLAGS -sMEMORY64=$WASM64_MEMORY64"
;;
esac

AC_CACHE_CHECK([whether compiler supports pointer authentication],
Expand Down
7 changes: 6 additions & 1 deletion configure.host
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,12 @@ case "${host}" in
;;

wasm32-*-*)
TARGET=wasm32; TARGETDIR=wasm32
TARGET=wasm32; TARGETDIR=wasm
SOURCES="ffi.c"
;;

wasm64-*-*)
TARGET=wasm64; TARGETDIR=wasm
SOURCES="ffi.c"
;;

Expand Down
Loading
0