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>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
ktokunaga.mail@gmail.com
Subject: [PATCH v2 2/4] configure: Enable to propagate -sMEMORY64 flag to Emscripten
Date: Thu, 7 Aug 2025 00:49:49 +0900 [thread overview]
Message-ID: <112b6882f9bd370deffb8637116fc44e043c250f.1754494089.git.ktokunaga.mail@gmail.com> (raw)
In-Reply-To: <cover.1754494089.git.ktokunaga.mail@gmail.com>
Currently there are some engines that don't support wasm64 (e.g. unsupported
on Safari[1]). To mitigate this issue, the configure script allows the user
to use Emscripten's compatibility feature, "-sMEMORY64=2" flag[2].
Emscripten's "-sMEMORY64=2" flag still enables 64bit pointers in C code. But
this flag lowers the output binary into wasm32, with limiting the maximum
memory size to 4GB. So QEMU can run on wasm32 engines.
[1] https://webassembly.org/features/
[2] https://emscripten.org/docs/tools_reference/settings_reference.html#memory64
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
---
configure | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
V2:
- Changed --wasm64-memory64 flag to --wasm64-32bit-address-limit to avoid
exposing the -sMEMORY64 value directly to the users. This can be
considered as a significant change from the previous version of this patch
so the Reviewed-by tag has been removed.
- Added a link to the Emscripten documentation about -sMEMORY64 in the
configure script.
diff --git a/configure b/configure
index 7f3893a42f..0587577da9 100755
--- a/configure
+++ b/configure
@@ -182,6 +182,10 @@ EXTRA_CXXFLAGS=""
EXTRA_OBJCFLAGS=""
EXTRA_LDFLAGS=""
+# The value is propagated to Emscripten's "-sMEMORY64" flag.
+# https://emscripten.org/docs/tools_reference/settings_reference.html#memory64
+wasm64_memory64=1
+
# Default value for a variable defining feature "foo".
# * foo="no" feature will only be used if --enable-foo arg is given
# * foo="" feature will be searched for, and if found, will be used
@@ -239,6 +243,8 @@ for opt do
;;
--without-default-features) default_feature="no"
;;
+ --wasm64-32bit-address-limit) wasm64_memory64="2"
+ ;;
esac
done
@@ -537,7 +543,7 @@ case "$cpu" in
CPU_CFLAGS="-m32"
;;
wasm64)
- CPU_CFLAGS="-m64 -sMEMORY64=1"
+ CPU_CFLAGS="-m64 -sMEMORY64=$wasm64_memory64"
;;
esac
@@ -795,6 +801,8 @@ for opt do
;;
--disable-rust) rust=disabled
;;
+ --wasm64-32bit-address-limit)
+ ;;
# everything else has the same name in configure and meson
--*) meson_option_parse "$opt" "$optarg"
;;
@@ -920,6 +928,8 @@ Advanced options (experts only):
--disable-containers don't use containers for cross-building
--container-engine=TYPE which container engine to use [$container_engine]
--gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
+ --wasm64-32bit-address-limit Restrict wasm64 address space to 32-bit (default
+ is to use the whole 64-bit range).
EOF
meson_options_help
cat << EOF
--
2.43.0
next prev parent reply other threads:[~2025-08-06 17:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 15:49 [PATCH v2 0/4] wasm: Enable 64bit guests on TCI using wasm64 Kohei Tokunaga
2025-08-06 15:49 ` [PATCH v2 1/4] meson: Add wasm64 support to the --cpu flag Kohei Tokunaga
2025-08-06 15:49 ` Kohei Tokunaga [this message]
2025-08-06 16:21 ` [PATCH v2 2/4] configure: Enable to propagate -sMEMORY64 flag to Emscripten Philippe Mathieu-Daudé
2025-08-06 18:00 ` Pierrick Bouvier
2025-08-06 15:49 ` [PATCH v2 3/4] dockerfiles: Add support for wasm64 to the wasm Dockerfile Kohei Tokunaga
2025-08-06 15:49 ` [PATCH v2 4/4] .gitlab-ci.d: Add build tests for wasm64 Kohei Tokunaga
2025-08-06 16:27 ` Philippe Mathieu-Daudé
2025-08-07 1:56 ` 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=112b6882f9bd370deffb8637116fc44e043c250f.1754494089.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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).