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.
This commit adds "--wasm64-memory64" flag to the configure script. This
takes the value to propagate to Emscripten's -sMEMORY64. 1(default) targets
wasm64 engines and 2 targets wasm32 engines with still enabling 64bit
pointers.
[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 | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 7f3893a42f..8573f84e26 100755
--- a/configure
+++ b/configure
@@ -182,6 +182,8 @@ EXTRA_CXXFLAGS=""
EXTRA_OBJCFLAGS=""
EXTRA_LDFLAGS=""
+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 +241,8 @@ for opt do
;;
--without-default-features) default_feature="no"
;;
+ --wasm64-memory64=*) wasm64_memory64="$optarg"
+ ;;
esac
done
@@ -537,7 +541,7 @@ case "$cpu" in
CPU_CFLAGS="-m32"
;;
wasm64)
- CPU_CFLAGS="-m64 -sMEMORY64=1"
+ CPU_CFLAGS="-m64 -sMEMORY64=$wasm64_memory64"
;;
esac
@@ -795,6 +799,8 @@ for opt do
;;
--disable-rust) rust=disabled
;;
+ --wasm64-memory64=*)
+ ;;
# everything else has the same name in configure and meson
--*) meson_option_parse "$opt" "$optarg"
;;
@@ -920,6 +926,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-memory64 Used only for wasm64 build. Set -sMEMORY64 of
+ Emscripten to 1(default) or 2 (choices: 1/2)
EOF
meson_options_help
cat << EOF
--
2.43.0
Hi Kohei,
On 4/8/25 14:57, Kohei Tokunaga wrote:
> 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.
>
> This commit adds "--wasm64-memory64" flag to the configure script. This
> takes the value to propagate to Emscripten's -sMEMORY64. 1(default) targets
> wasm64 engines and 2 targets wasm32 engines with still enabling 64bit
> pointers.
>
> [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 | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index 7f3893a42f..8573f84e26 100755
> --- a/configure
> +++ b/configure
> @@ -182,6 +182,8 @@ EXTRA_CXXFLAGS=""
> EXTRA_OBJCFLAGS=""
> EXTRA_LDFLAGS=""
>
> +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 +241,8 @@ for opt do
> ;;
> --without-default-features) default_feature="no"
> ;;
> + --wasm64-memory64=*) wasm64_memory64="$optarg"
> + ;;
> esac
> done
>
> @@ -537,7 +541,7 @@ case "$cpu" in
> CPU_CFLAGS="-m32"
> ;;
> wasm64)
> - CPU_CFLAGS="-m64 -sMEMORY64=1"
> + CPU_CFLAGS="-m64 -sMEMORY64=$wasm64_memory64"
> ;;
> esac
>
> @@ -795,6 +799,8 @@ for opt do
> ;;
> --disable-rust) rust=disabled
> ;;
> + --wasm64-memory64=*)
> + ;;
> # everything else has the same name in configure and meson
> --*) meson_option_parse "$opt" "$optarg"
> ;;
> @@ -920,6 +926,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-memory64 Used only for wasm64 build. Set -sMEMORY64 of
> + Emscripten to 1(default) or 2 (choices: 1/2)
I wouldn't expose "1" or "2" to the users. Instead, keep 1 as internal
default, and provide the --wasm64-32bit-address-limit option which sets
internal value to 2. Configure help could be:
--wasm64-32bit-address-limit Restrict wasm64 address space to
32-bit (default is to use the whole
64-bit range).
WDYT?
Hi Philippe, Thanks for the suggestion. > On 4/8/25 14:57, Kohei Tokunaga wrote: > > 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. > > > > This commit adds "--wasm64-memory64" flag to the configure script. This > > takes the value to propagate to Emscripten's -sMEMORY64. 1(default) targets > > wasm64 engines and 2 targets wasm32 engines with still enabling 64bit > > pointers. > > > > [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 | 10 +++++++++- > > 1 file changed, 9 insertions(+), 1 deletion(-) > > > > diff --git a/configure b/configure > > index 7f3893a42f..8573f84e26 100755 > > --- a/configure > > +++ b/configure > > @@ -182,6 +182,8 @@ EXTRA_CXXFLAGS="" > > EXTRA_OBJCFLAGS="" > > EXTRA_LDFLAGS="" > > > > +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 +241,8 @@ for opt do > > ;; > > --without-default-features) default_feature="no" > > ;; > > + --wasm64-memory64=*) wasm64_memory64="$optarg" > > + ;; > > esac > > done > > > > @@ -537,7 +541,7 @@ case "$cpu" in > > CPU_CFLAGS="-m32" > > ;; > > wasm64) > > - CPU_CFLAGS="-m64 -sMEMORY64=1" > > + CPU_CFLAGS="-m64 -sMEMORY64=$wasm64_memory64" > > ;; > > esac > > > > @@ -795,6 +799,8 @@ for opt do > > ;; > > --disable-rust) rust=disabled > > ;; > > + --wasm64-memory64=*) > > + ;; > > # everything else has the same name in configure and meson > > --*) meson_option_parse "$opt" "$optarg" > > ;; > > @@ -920,6 +926,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-memory64 Used only for wasm64 build. Set -sMEMORY64 of > > + Emscripten to 1(default) or 2 (choices: 1/2) > > I wouldn't expose "1" or "2" to the users. Instead, keep 1 as internal > default, and provide the --wasm64-32bit-address-limit option which sets > internal value to 2. Configure help could be: > > --wasm64-32bit-address-limit Restrict wasm64 address space to > 32-bit (default is to use the whole > 64-bit range). > > WDYT? It looks good to me. I'll update the patch. Regards, Kohei
On 8/4/25 5:57 AM, Kohei Tokunaga wrote: > 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. > > This commit adds "--wasm64-memory64" flag to the configure script. This > takes the value to propagate to Emscripten's -sMEMORY64. 1(default) targets > wasm64 engines and 2 targets wasm32 engines with still enabling 64bit > pointers. > > [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 | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) It could be worth adding the link to documentation in commit description directly in configure also. As well, the --wasm64-memory64 option help could explain that in a few words. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Hi Pierrick, thanks for the feedback. > It could be worth adding the link to documentation in commit description > directly in configure also. > As well, the --wasm64-memory64 option help could explain that in a few > words. I'll add the explanation in the configure script in the next version of this patch series. Regards, Kohei
© 2016 - 2025 Red Hat, Inc.