Commit c6f975df5b for qemu.org

commit c6f975df5b0ba96b15b882e7ab5b23a4538f52ed
Author: Kohei Tokunaga <ktokunaga.mail@gmail.com>
Date:   Mon Aug 4 21:57:15 2025 +0900

    configure: Enable to propagate -sMEMORY64 flag to Emscripten

    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>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
    Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
    Message-ID: <a2f068c7884a629fe3e4b297368d70b0956ab048.1768308374.git.ktokunaga.mail@gmail.com>
    Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

diff --git a/configure b/configure
index 92bfc5f976..326d27dab1 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

@@ -521,7 +527,7 @@ case "$cpu" in
     CPU_CFLAGS="-m32"
     ;;
   wasm64)
-    CPU_CFLAGS="-m64 -sMEMORY64=1"
+    CPU_CFLAGS="-m64 -sMEMORY64=$wasm64_memory64"
     ;;
 esac

@@ -779,6 +785,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"
   ;;
@@ -904,6 +912,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