From: Kohei Tokunaga <ktokunaga.mail@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Thomas Huth" <thuth@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Daniel P . Berrangé" <berrange@redhat.com>,
"Kohei Tokunaga" <ktokunaga.mail@gmail.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
"Richard Henderson" <richard.henderson@linaro.org>
Subject: [PATCH v4 0/4] wasm: Enable 64bit guests on TCI using wasm64
Date: Fri, 9 Jan 2026 02:11:24 +0900 [thread overview]
Message-ID: <cover.1767886100.git.ktokunaga.mail@gmail.com> (raw)
V4:
- Rebased on the recent tree.
V3:
- Renamed the build tests on GitLab CI("build-wasm32" ->
"build-wasm32-32bit", "build-wasm-wasm64" -> "build-wasm64-64bit",
"build-wasm-wasm64l" -> "build-wasm64-32bit"). The same change has also
been applied to container-cross.yml.
V2:
- Added a link to the Emscripten documentation about -sMEMORY64 in the
configure script.
- Changed --wasm64-memory64 flag to --wasm64-32bit-address-limit to avoid
exposing the -sMEMORY64 value directly to the users.
- Fixed GitLab CI to use --wasm64-32bit-address-limit instead of
--wasm64-memory64.
V1:
This patch series enables the TCI of the Wasm build to run 64bit
guests. Unlike the previous series[1], this patch series is implemented by
adding support for WebAssembly's "wasm64" target which enables 64bit
pointers.
In the previous discussion[2], the main challenge of using wasm64 was its
limited adoption, particularly the lack of support in our dependency
(libffi) and some engines such as Safari.
For libffi, I've completed the addition of wasm64 support upstream[3] so it
can be used.
To support wasm32 engines, this patch uses Emscripten's compatibility
feature, -sMEMORY64=2 flag[4]. This flag still enables 64bit pointers in the
C code while Emscripten lowers the output binary to wasm32 and limits the
maximum memory size to 4GB. As a result, QEMU can run on wasm32 engiens
while still supporting 64bit guests.
# Overview of the build process
To compile QEMU with Emscripten, the following dependencies are required.
The emsdk-wasm-cross.docker environment includes all necessary components
and can be used as the build environment:
- Emscripten SDK (emsdk) v4.0.10
- Libraries cross-compiled with Emscripten (please see also
emsdk-wasm-cross.docker for build steps)
- GLib v2.84.0
- zlib v1.3.1
- libffi v3.5.2
- Pixman v0.44.2
The configure script supports --cpu=wasm64 flag to compile QEMU with 64bit
pointer support.
emconfigure ./configure --cpu=wasm64 \
--static --disable-tools \
--target-list=x86_64-softmmu \
--enable-tcg-interpreter
emmake make -j$(nproc)
If the output needs to run on wasm32 engines, use
--wasm64-32bit-address-limit flag. This flag enables Emscripten's
-sMEMORY64=2 flag[4]. (Note: --wasm64-memory64=2 flag in the V1 patch has
been renamed to --wasm64-32bit-address-limit in V2)
emconfigure ./configure --cpu=wasm64 --wasm64-32bit-address-limit \
--static --disable-tools \
--target-list=x86_64-softmmu \
--enable-tcg-interpreter
emmake make -j$(nproc)
Either of the above commands generates the following files:
- qemu-system-x86_64.js
- qemu-system-x86_64.wasm
Guest images can be packaged using Emscripten's file_packager.py tool.
For example, if the images are stored in a directory named "pack", the
following command packages them, allowing QEMU to access them through
Emscripten's virtual filesystem:
/path/to/file_packager.py qemu-system-x86_64.data --preload pack > load.js
This process generates the following files:
- qemu-system-x86_64.data
- load.js
Emscripten allows passing arguments to the QEMU command via the Module
object in JavaScript:
Module['arguments'] = [
'-nographic', '-m', '512M',
'-L', 'pack/',
'-drive', 'if=virtio,format=raw,file=pack/rootfs.bin',
'-kernel', 'pack/bzImage',
'-append', 'earlyprintk=ttyS0 console=ttyS0 root=/dev/vda loglevel=7',
];
The sample repository[5] (tcidev64 branch) provides a complete setup,
including an HTML file that implements a terminal UI.
[1] https://lists.nongnu.org/archive/html/qemu-devel/2025-05/msg05376.html
[2] https://lists.nongnu.org/archive/html/qemu-devel/2025-04/msg01795.html
[3] https://github.com/libffi/libffi/pull/927
[4] https://emscripten.org/docs/tools_reference/settings_reference.html#memory64
[5] https://github.com/ktock/qemu-wasm-sample/tree/tcidev64
Kohei Tokunaga (4):
meson: Add wasm64 support to the --cpu flag
configure: Enable to propagate -sMEMORY64 flag to Emscripten
dockerfiles: Add support for wasm64 to the wasm Dockerfile
.gitlab-ci.d: Add build tests for wasm64
.gitlab-ci.d/buildtest.yml | 26 ++++++++++++++---
.gitlab-ci.d/container-cross.yml | 20 +++++++++++--
.gitlab-ci.d/container-template.yml | 4 ++-
.gitlab-ci.d/containers.yml | 4 ++-
MAINTAINERS | 2 +-
configure | 16 +++++++++-
meson.build | 4 +--
...2-cross.docker => emsdk-wasm-cross.docker} | 29 ++++++++++++++-----
8 files changed, 86 insertions(+), 19 deletions(-)
rename tests/docker/dockerfiles/{emsdk-wasm32-cross.docker => emsdk-wasm-cross.docker} (86%)
--
2.43.0
next reply other threads:[~2026-01-08 17:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-08 17:11 Kohei Tokunaga [this message]
2026-01-08 17:11 ` [PATCH v4 1/4] meson: Add wasm64 support to the --cpu flag Kohei Tokunaga
2026-01-08 17:11 ` [PATCH v4 2/4] configure: Enable to propagate -sMEMORY64 flag to Emscripten Kohei Tokunaga
2026-01-08 17:11 ` [PATCH v4 3/4] dockerfiles: Add support for wasm64 to the wasm Dockerfile Kohei Tokunaga
2026-01-09 20:49 ` Richard Henderson
2026-01-12 15:03 ` Kohei Tokunaga
2026-01-08 17:11 ` [PATCH v4 4/4] .gitlab-ci.d: Add build tests for wasm64 Kohei Tokunaga
2026-01-09 20:52 ` Richard Henderson
2026-01-12 15:04 ` Kohei Tokunaga
2026-01-13 14:00 ` Kohei Tokunaga
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1767886100.git.ktokunaga.mail@gmail.com \
--to=ktokunaga.mail@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=berrange@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.