has_int128_type is set to false on emscripten as of now to avoid errors by
libffi. And tests aren't integrated with Wasm execution environment as of
now so this commit disables tests.
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
---
configs/meson/emscripten.txt | 6 ++++++
configure | 7 +++++++
meson.build | 14 ++++++++++----
meson_options.txt | 2 +-
scripts/meson-buildoptions.sh | 2 +-
5 files changed, 25 insertions(+), 6 deletions(-)
create mode 100644 configs/meson/emscripten.txt
diff --git a/configs/meson/emscripten.txt b/configs/meson/emscripten.txt
new file mode 100644
index 0000000000..054b263814
--- /dev/null
+++ b/configs/meson/emscripten.txt
@@ -0,0 +1,6 @@
+[built-in options]
+c_args = ['-Wno-unused-command-line-argument','-g','-O3','-pthread']
+cpp_args = ['-Wno-unused-command-line-argument','-g','-O3','-pthread']
+objc_args = ['-Wno-unused-command-line-argument','-g','-O3','-pthread']
+c_link_args = ['-Wno-unused-command-line-argument','-g','-O3','-pthread','-sASYNCIFY=1','-sPROXY_TO_PTHREAD=1','-sFORCE_FILESYSTEM','-sALLOW_TABLE_GROWTH','-sTOTAL_MEMORY=2GB','-sWASM_BIGINT','-sEXPORT_ES6=1','-sASYNCIFY_IMPORTS=ffi_call_js','-sEXPORTED_RUNTIME_METHODS=addFunction,removeFunction,TTY,FS']
+cpp_link_args = ['-Wno-unused-command-line-argument','-g','-O3','-pthread','-sASYNCIFY=1','-sPROXY_TO_PTHREAD=1','-sFORCE_FILESYSTEM','-sALLOW_TABLE_GROWTH','-sTOTAL_MEMORY=2GB','-sWASM_BIGINT','-sEXPORT_ES6=1','-sASYNCIFY_IMPORTS=ffi_call_js','-sEXPORTED_RUNTIME_METHODS=addFunction,removeFunction,TTY,FS']
diff --git a/configure b/configure
index 02f1dd2311..a1fe6e11cd 100755
--- a/configure
+++ b/configure
@@ -360,6 +360,10 @@ elif check_define __NetBSD__; then
host_os=netbsd
elif check_define __APPLE__; then
host_os=darwin
+elif check_define EMSCRIPTEN ; then
+ host_os=emscripten
+ cpu=wasm32
+ cross_compile="yes"
else
# This is a fatal error, but don't report it yet, because we
# might be going to just print the --help text, or it might
@@ -526,6 +530,9 @@ case "$cpu" in
linux_arch=x86
CPU_CFLAGS="-m64"
;;
+ wasm32)
+ CPU_CFLAGS="-m32"
+ ;;
esac
if test -n "$host_arch" && {
diff --git a/meson.build b/meson.build
index 41f68d3806..bcf1e33ddf 100644
--- a/meson.build
+++ b/meson.build
@@ -50,9 +50,9 @@ genh = []
qapi_trace_events = []
bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin']
-supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
+supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux', 'emscripten']
supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64',
- 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64']
+ 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64', 'wasm32']
cpu = host_machine.cpu_family()
@@ -353,6 +353,8 @@ foreach lang : all_languages
# endif
#endif''')
# ok
+ elif compiler.get_id() == 'emscripten'
+ # ok
else
error('You either need GCC v7.4 or Clang v10.0 (or XCode Clang v15.0) to compile QEMU')
endif
@@ -514,6 +516,8 @@ ucontext_probe = '''
supported_backends = []
if host_os == 'windows'
supported_backends += ['windows']
+elif host_os == 'emscripten'
+ supported_backends += ['fiber']
else
if host_os != 'darwin' and cc.links(ucontext_probe)
supported_backends += ['ucontext']
@@ -2962,7 +2966,7 @@ config_host_data.set('CONFIG_ATOMIC64', cc.links('''
return 0;
}''', args: qemu_isa_flags))
-has_int128_type = cc.compiles('''
+has_int128_type = host_os != 'emscripten' and cc.compiles('''
__int128_t a;
__uint128_t b;
int main(void) { b = a; }''')
@@ -4456,7 +4460,9 @@ subdir('scripts')
subdir('tools')
subdir('pc-bios')
subdir('docs')
-subdir('tests')
+if host_os != 'emscripten'
+ subdir('tests')
+endif
if gtk.found()
subdir('po')
endif
diff --git a/meson_options.txt b/meson_options.txt
index 59d973bca0..6d73aafe91 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -34,7 +34,7 @@ option('fuzzing_engine', type : 'string', value : '',
option('trace_file', type: 'string', value: 'trace',
description: 'Trace file prefix for simple backend')
option('coroutine_backend', type: 'combo',
- choices: ['ucontext', 'sigaltstack', 'windows', 'auto'],
+ choices: ['ucontext', 'sigaltstack', 'windows', 'auto', 'fiber'],
value: 'auto', description: 'coroutine backend to use')
# Everything else can be set via --enable/--disable-* option
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index 3e8e00852b..cbba2f248c 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -80,7 +80,7 @@ meson_options_help() {
printf "%s\n" ' --tls-priority=VALUE Default TLS protocol/cipher priority string'
printf "%s\n" ' [NORMAL]'
printf "%s\n" ' --with-coroutine=CHOICE coroutine backend to use (choices:'
- printf "%s\n" ' auto/sigaltstack/ucontext/windows)'
+ printf "%s\n" ' auto/fiber/sigaltstack/ucontext/windows)'
printf "%s\n" ' --with-pkgversion=VALUE use specified string as sub-version of the'
printf "%s\n" ' package'
printf "%s\n" ' --with-suffix=VALUE Suffix for QEMU data/modules/config directories'
--
2.25.1
Cc'ing Pierrick
On 7/4/25 16:45, Kohei Tokunaga wrote:
> has_int128_type is set to false on emscripten as of now to avoid errors by
> libffi. And tests aren't integrated with Wasm execution environment as of
> now so this commit disables tests.
>
> Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
> ---
> configs/meson/emscripten.txt | 6 ++++++
> configure | 7 +++++++
> meson.build | 14 ++++++++++----
> meson_options.txt | 2 +-
> scripts/meson-buildoptions.sh | 2 +-
> 5 files changed, 25 insertions(+), 6 deletions(-)
> create mode 100644 configs/meson/emscripten.txt
>
> diff --git a/configs/meson/emscripten.txt b/configs/meson/emscripten.txt
> new file mode 100644
> index 0000000000..054b263814
> --- /dev/null
> +++ b/configs/meson/emscripten.txt
> @@ -0,0 +1,6 @@
> +[built-in options]
> +c_args = ['-Wno-unused-command-line-argument','-g','-O3','-pthread']
> +cpp_args = ['-Wno-unused-command-line-argument','-g','-O3','-pthread']
> +objc_args = ['-Wno-unused-command-line-argument','-g','-O3','-pthread']
> +c_link_args = ['-Wno-unused-command-line-argument','-g','-O3','-pthread','-sASYNCIFY=1','-sPROXY_TO_PTHREAD=1','-sFORCE_FILESYSTEM','-sALLOW_TABLE_GROWTH','-sTOTAL_MEMORY=2GB','-sWASM_BIGINT','-sEXPORT_ES6=1','-sASYNCIFY_IMPORTS=ffi_call_js','-sEXPORTED_RUNTIME_METHODS=addFunction,removeFunction,TTY,FS']
> +cpp_link_args = ['-Wno-unused-command-line-argument','-g','-O3','-pthread','-sASYNCIFY=1','-sPROXY_TO_PTHREAD=1','-sFORCE_FILESYSTEM','-sALLOW_TABLE_GROWTH','-sTOTAL_MEMORY=2GB','-sWASM_BIGINT','-sEXPORT_ES6=1','-sASYNCIFY_IMPORTS=ffi_call_js','-sEXPORTED_RUNTIME_METHODS=addFunction,removeFunction,TTY,FS']
> diff --git a/configure b/configure
> index 02f1dd2311..a1fe6e11cd 100755
> --- a/configure
> +++ b/configure
> @@ -360,6 +360,10 @@ elif check_define __NetBSD__; then
> host_os=netbsd
> elif check_define __APPLE__; then
> host_os=darwin
> +elif check_define EMSCRIPTEN ; then
> + host_os=emscripten
> + cpu=wasm32
> + cross_compile="yes"
> else
> # This is a fatal error, but don't report it yet, because we
> # might be going to just print the --help text, or it might
> @@ -526,6 +530,9 @@ case "$cpu" in
> linux_arch=x86
> CPU_CFLAGS="-m64"
> ;;
> + wasm32)
> + CPU_CFLAGS="-m32"
> + ;;
> esac
>
> if test -n "$host_arch" && {
> diff --git a/meson.build b/meson.build
> index 41f68d3806..bcf1e33ddf 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -50,9 +50,9 @@ genh = []
> qapi_trace_events = []
>
> bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin']
> -supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
> +supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux', 'emscripten']
> supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64',
> - 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64']
> + 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64', 'wasm32']
>
> cpu = host_machine.cpu_family()
>
> @@ -353,6 +353,8 @@ foreach lang : all_languages
> # endif
> #endif''')
> # ok
> + elif compiler.get_id() == 'emscripten'
> + # ok
> else
> error('You either need GCC v7.4 or Clang v10.0 (or XCode Clang v15.0) to compile QEMU')
> endif
> @@ -514,6 +516,8 @@ ucontext_probe = '''
> supported_backends = []
> if host_os == 'windows'
> supported_backends += ['windows']
> +elif host_os == 'emscripten'
> + supported_backends += ['fiber']
> else
> if host_os != 'darwin' and cc.links(ucontext_probe)
> supported_backends += ['ucontext']
> @@ -2962,7 +2966,7 @@ config_host_data.set('CONFIG_ATOMIC64', cc.links('''
> return 0;
> }''', args: qemu_isa_flags))
>
> -has_int128_type = cc.compiles('''
> +has_int128_type = host_os != 'emscripten' and cc.compiles('''
> __int128_t a;
> __uint128_t b;
> int main(void) { b = a; }''')
> @@ -4456,7 +4460,9 @@ subdir('scripts')
> subdir('tools')
> subdir('pc-bios')
> subdir('docs')
> -subdir('tests')
> +if host_os != 'emscripten'
> + subdir('tests')
> +endif
> if gtk.found()
> subdir('po')
> endif
> diff --git a/meson_options.txt b/meson_options.txt
> index 59d973bca0..6d73aafe91 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -34,7 +34,7 @@ option('fuzzing_engine', type : 'string', value : '',
> option('trace_file', type: 'string', value: 'trace',
> description: 'Trace file prefix for simple backend')
> option('coroutine_backend', type: 'combo',
> - choices: ['ucontext', 'sigaltstack', 'windows', 'auto'],
> + choices: ['ucontext', 'sigaltstack', 'windows', 'auto', 'fiber'],
> value: 'auto', description: 'coroutine backend to use')
>
> # Everything else can be set via --enable/--disable-* option
> diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
> index 3e8e00852b..cbba2f248c 100644
> --- a/scripts/meson-buildoptions.sh
> +++ b/scripts/meson-buildoptions.sh
> @@ -80,7 +80,7 @@ meson_options_help() {
> printf "%s\n" ' --tls-priority=VALUE Default TLS protocol/cipher priority string'
> printf "%s\n" ' [NORMAL]'
> printf "%s\n" ' --with-coroutine=CHOICE coroutine backend to use (choices:'
> - printf "%s\n" ' auto/sigaltstack/ucontext/windows)'
> + printf "%s\n" ' auto/fiber/sigaltstack/ucontext/windows)'
> printf "%s\n" ' --with-pkgversion=VALUE use specified string as sub-version of the'
> printf "%s\n" ' package'
> printf "%s\n" ' --with-suffix=VALUE Suffix for QEMU data/modules/config directories'
On 4/9/25 12:55, Philippe Mathieu-Daudé wrote: > Cc'ing Pierrick > > On 7/4/25 16:45, Kohei Tokunaga wrote: >> has_int128_type is set to false on emscripten as of now to avoid errors by >> libffi. What is the error here? How hard would it be to test for it? >> And tests aren't integrated with Wasm execution environment as of >> now so this commit disables tests. Perhaps it would be enough to add [binaries] exe_wrapper = 'node' to the emscripten.txt file? >> +[built-in options] >> +c_args = ['-Wno-unused-command-line-argument','-g','-O3','-pthread'] >> +cpp_args = ['-Wno-unused-command-line-argument','-g','-O3','-pthread'] >> +objc_args = ['-Wno-unused-command-line-argument','-g','-O3','-pthread'] >> +c_link_args = ['-Wno-unused-command-line-argument','-g','-O3','- >> pthread','-sASYNCIFY=1','-sPROXY_TO_PTHREAD=1','-sFORCE_FILESYSTEM','- >> sALLOW_TABLE_GROWTH','-sTOTAL_MEMORY=2GB','-sWASM_BIGINT','- >> sEXPORT_ES6=1','-sASYNCIFY_IMPORTS=ffi_call_js','- >> sEXPORTED_RUNTIME_METHODS=addFunction,removeFunction,TTY,FS'] >> +cpp_link_args = ['-Wno-unused-command-line-argument','-g','-O3','- >> pthread','-sASYNCIFY=1','-sPROXY_TO_PTHREAD=1','-sFORCE_FILESYSTEM','- >> sALLOW_TABLE_GROWTH','-sTOTAL_MEMORY=2GB','-sWASM_BIGINT','- >> sEXPORT_ES6=1','-sASYNCIFY_IMPORTS=ffi_call_js','- >> sEXPORTED_RUNTIME_METHODS=addFunction,removeFunction,TTY,FS'] At least -g -O3 -pthread should not be necessary. For -Wno-unused-command-line-argument what are the warnings/errors that you are getting? >> +elif host_os == 'emscripten' >> + supported_backends += ['fiber'] Can you rename the backend to 'wasm' since the 'windows' backend also uses an API called Fibers? Otherwise the changes look good. Paolo
Hi Paolo, thank you for the comments.
> >> has_int128_type is set to false on emscripten as of now to avoid
errors by
> >> libffi.
>
> What is the error here? How hard would it be to test for it?
When has_int128_type=true, I encountered a runtime error from libffi. To
reproduce this, we need to actually execute a libffi call with 128-bit
arguments.
> Uncaught TypeError: Cannot convert 1079505232 to a BigInt
> at ffi_call_js (out.js:702:37)
> at qemu-system-x86_64.wasm.ffi_call (qemu-system-x86_64.wasm:0xa37712)
> at qemu-system-x86_64.wasm.tcg_qemu_tb_exec_tci
(qemu-system-x86_64.wasm:0x65f440)
> at qemu-system-x86_64.wasm.tcg_qemu_tb_exec
(qemu-system-x86_64.wasm:0x65edff)
> at qemu-system-x86_64.wasm.cpu_tb_exec
(qemu-system-x86_64.wasm:0x6762c0)
> at qemu-system-x86_64.wasm.cpu_exec_loop
(qemu-system-x86_64.wasm:0x677c84)
> at qemu-system-x86_64.wasm.dynCall_iii
(qemu-system-x86_64.wasm:0xab9014)
> at ret.<computed> (out.js:6016:24)
> at invoke_iii (out.js:7574:10)
> at qemu-system-x86_64.wasm.cpu_exec_setjmp
(qemu-system-x86_64.wasm:0x676db8)
> >> And tests aren't integrated with Wasm execution environment as of
> >> now so this commit disables tests.
>
> Perhaps it would be enough to add
>
> [binaries]
> exe_wrapper = 'node'
>
> to the emscripten.txt file?
Thank you for the suggestion. I'll explore this approach.
> >> +[built-in options]
> >> +c_args = ['-Wno-unused-command-line-argument','-g','-O3','-pthread']
> >> +cpp_args = ['-Wno-unused-command-line-argument','-g','-O3','-pthread']
> >> +objc_args =
['-Wno-unused-command-line-argument','-g','-O3','-pthread']
> >> +c_link_args = ['-Wno-unused-command-line-argument','-g','-O3','-
> >> pthread','-sASYNCIFY=1','-sPROXY_TO_PTHREAD=1','-sFORCE_FILESYSTEM','-
> >> sALLOW_TABLE_GROWTH','-sTOTAL_MEMORY=2GB','-sWASM_BIGINT','-
> >> sEXPORT_ES6=1','-sASYNCIFY_IMPORTS=ffi_call_js','-
> >> sEXPORTED_RUNTIME_METHODS=addFunction,removeFunction,TTY,FS']
> >> +cpp_link_args = ['-Wno-unused-command-line-argument','-g','-O3','-
> >> pthread','-sASYNCIFY=1','-sPROXY_TO_PTHREAD=1','-sFORCE_FILESYSTEM','-
> >> sALLOW_TABLE_GROWTH','-sTOTAL_MEMORY=2GB','-sWASM_BIGINT','-
> >> sEXPORT_ES6=1','-sASYNCIFY_IMPORTS=ffi_call_js','-
> >> sEXPORTED_RUNTIME_METHODS=addFunction,removeFunction,TTY,FS']
>
> At least -g -O3 -pthread should not be necessary.
Thank you for the suggestion. -sPROXY_TO_PTHREAD flag used in c_link_args
always requires -pthread, even during configuration. Otherwise, emcc returns
an error like:
> emcc: error: -sPROXY_TO_PTHREAD requires -pthread to work!
So I think -pthread needs to be included in c_link_args at minimum. I'll try
to remove other flags in the next version of the series.
> For -Wno-unused-command-line-argument what are the warnings/errors that
> you are getting?
I encountered the following error when compiling QEMU:
> clang: error: argument unused during compilation: '-no-pie'
[-Werror,-Wunused-command-line-argument]
It seems Emscripten doesn't support the -no-pie flag, and this wasn't caught
during the configure phase. It seems that removing
-Wno-unused-command-line-argument would require the following change in
meson.build, but I'm open to better approaches.
> -if not get_option('b_pie')
> +if not get_option('b_pie') and host_os != 'emscripten'
> qemu_common_flags += cc.get_supported_arguments('-fno-pie', '-no-pie')
> endif
> >> +elif host_os == 'emscripten'
> >> + supported_backends += ['fiber']
>
> Can you rename the backend to 'wasm' since the 'windows' backend also
> uses an API called Fibers?
Sure, I'll rename the coroutine backend in the next version of the series.
On Thu, Apr 10, 2025 at 2:24 PM Kohei Tokunaga <ktokunaga.mail@gmail.com> wrote:
> > >> has_int128_type is set to false on emscripten as of now to avoid errors by
> > >> libffi.
> >
> > What is the error here? How hard would it be to test for it?
>
> When has_int128_type=true, I encountered a runtime error from libffi. To
> reproduce this, we need to actually execute a libffi call with 128-bit
> arguments.
>
> > Uncaught TypeError: Cannot convert 1079505232 to a BigInt
> > at ffi_call_js (out.js:702:37)
> > at qemu-system-x86_64.wasm.ffi_call (qemu-system-x86_64.wasm:0xa37712)
> > at qemu-system-x86_64.wasm.tcg_qemu_tb_exec_tci (qemu-system-x86_64.wasm:0x65f440)
> > at qemu-system-x86_64.wasm.tcg_qemu_tb_exec (qemu-system-x86_64.wasm:0x65edff)
> > at qemu-system-x86_64.wasm.cpu_tb_exec (qemu-system-x86_64.wasm:0x6762c0)
> > at qemu-system-x86_64.wasm.cpu_exec_loop (qemu-system-x86_64.wasm:0x677c84)
> > at qemu-system-x86_64.wasm.dynCall_iii (qemu-system-x86_64.wasm:0xab9014)
> > at ret.<computed> (out.js:6016:24)
> > at invoke_iii (out.js:7574:10)
> > at qemu-system-x86_64.wasm.cpu_exec_setjmp (qemu-system-x86_64.wasm:0x676db8)
Ok, I guess a comment mentioning that it's a libffi limitation is enough.
> > At least -g -O3 -pthread should not be necessary.
>
> Thank you for the suggestion. -sPROXY_TO_PTHREAD flag used in c_link_args
> always requires -pthread, even during configuration. Otherwise, emcc returns
> an error like:
>
> > emcc: error: -sPROXY_TO_PTHREAD requires -pthread to work!
>
> So I think -pthread needs to be included in c_link_args at minimum. I'll try
> to remove other flags in the next version of the series.
Reading more about -sPROXY_TO_PTHREAD it seems that you need it for
all calls to emcc, even when compiling, so it's better to leave it in
everywhere.
> > For -Wno-unused-command-line-argument what are the warnings/errors that
> > you are getting?
>
> I encountered the following error when compiling QEMU:
>
> > clang: error: argument unused during compilation: '-no-pie' [-Werror,-Wunused-command-line-argument]
>
> It seems Emscripten doesn't support the -no-pie flag, and this wasn't caught
> during the configure phase. It seems that removing
> -Wno-unused-command-line-argument would require the following change in
> meson.build, but I'm open to better approaches.
>
> > -if not get_option('b_pie')
> > +if not get_option('b_pie') and host_os != 'emscripten'
> > qemu_common_flags += cc.get_supported_arguments('-fno-pie', '-no-pie')
> > endif
Meson should have passed the -Werror=unused-command-line-argument flag
when doing the above test (CLikeCompiler._has_multi_arguments ->
has_arguments -> Compiler.compiles -> _build_wrapper ->
build_wrapper_args -> ClangCompiler.get_compiler_check_args). It would
be great if you can check what's wrong in this theory so perhaps meson
can be fixed, or at least send here a meson-log.txt.
My suggestion is (if possible) to split out the parts of this series
that are enough to run QEMU under TCI, and get those in as quickly as
possible. The TCG backend can come second.
Thanks,
Paolo
Hi Paolo,
> > > >> has_int128_type is set to false on emscripten as of now to avoid
errors by
> > > >> libffi.
> > >
> > > What is the error here? How hard would it be to test for it?
> >
> > When has_int128_type=true, I encountered a runtime error from libffi. To
> > reproduce this, we need to actually execute a libffi call with 128-bit
> > arguments.
> >
> > > Uncaught TypeError: Cannot convert 1079505232 to a BigInt
> > > at ffi_call_js (out.js:702:37)
> > > at qemu-system-x86_64.wasm.ffi_call
(qemu-system-x86_64.wasm:0xa37712)
> > > at qemu-system-x86_64.wasm.tcg_qemu_tb_exec_tci
(qemu-system-x86_64.wasm:0x65f440)
> > > at qemu-system-x86_64.wasm.tcg_qemu_tb_exec
(qemu-system-x86_64.wasm:0x65edff)
> > > at qemu-system-x86_64.wasm.cpu_tb_exec
(qemu-system-x86_64.wasm:0x6762c0)
> > > at qemu-system-x86_64.wasm.cpu_exec_loop
(qemu-system-x86_64.wasm:0x677c84)
> > > at qemu-system-x86_64.wasm.dynCall_iii
(qemu-system-x86_64.wasm:0xab9014)
> > > at ret.<computed> (out.js:6016:24)
> > > at invoke_iii (out.js:7574:10)
> > > at qemu-system-x86_64.wasm.cpu_exec_setjmp
(qemu-system-x86_64.wasm:0x676db8)
>
> Ok, I guess a comment mentioning that it's a libffi limitation is enough.
>
> > > At least -g -O3 -pthread should not be necessary.
> >
> > Thank you for the suggestion. -sPROXY_TO_PTHREAD flag used in
c_link_args
> > always requires -pthread, even during configuration. Otherwise, emcc
returns
> > an error like:
> >
> > > emcc: error: -sPROXY_TO_PTHREAD requires -pthread to work!
> >
> > So I think -pthread needs to be included in c_link_args at minimum.
I'll try
> > to remove other flags in the next version of the series.
>
> Reading more about -sPROXY_TO_PTHREAD it seems that you need it for
> all calls to emcc, even when compiling, so it's better to leave it in
> everywhere.
>
> > > For -Wno-unused-command-line-argument what are the warnings/errors
that
> > > you are getting?
> >
> > I encountered the following error when compiling QEMU:
> >
> > > clang: error: argument unused during compilation: '-no-pie'
[-Werror,-Wunused-command-line-argument]
> >
> > It seems Emscripten doesn't support the -no-pie flag, and this wasn't
caught
> > during the configure phase. It seems that removing
> > -Wno-unused-command-line-argument would require the following change in
> > meson.build, but I'm open to better approaches.
> >
> > > -if not get_option('b_pie')
> > > +if not get_option('b_pie') and host_os != 'emscripten'
> > > qemu_common_flags += cc.get_supported_arguments('-fno-pie',
'-no-pie')
> > > endif
>
> Meson should have passed the -Werror=unused-command-line-argument flag
> when doing the above test (CLikeCompiler._has_multi_arguments ->
> has_arguments -> Compiler.compiles -> _build_wrapper ->
> build_wrapper_args -> ClangCompiler.get_compiler_check_args). It would
> be great if you can check what's wrong in this theory so perhaps meson
> can be fixed, or at least send here a meson-log.txt.
According to meson-log.txt as shown below,
-Werror=unused-command-line-argument was passed to the compiler, but it
didn't catch the warning.
> Working directory: /build/meson-private/tmp4q_5wl_9
> Code:
> extern int i;
> int i;
>
> -----------
> Command line: `/emsdk/upstream/emscripten/emcc -m32
/build/meson-private/tmp4q_5wl_9/testfile.c -o
/build/meson-private/tmp4q_5wl_9/output.o -c -D_FILE_OFFSET_BITS=64 -O0
-Werror=implicit-function-declaration -Werror=unknown-warning-option
-Werror=unused-command-line-argument -fno-pie` -> 0
> Compiler for C supports arguments -fno-pie: YES
> Running compile:
> Working directory: /build/meson-private/tmpl9yy_8gs
> Code:
> extern int i;
> int i;
>
> -----------
> Command line: `/emsdk/upstream/emscripten/emcc -m32
/build/meson-private/tmpl9yy_8gs/testfile.c -o
/build/meson-private/tmpl9yy_8gs/output.o -c -D_FILE_OFFSET_BITS=64 -O0
-Werror=implicit-function-declaration -Werror=unknown-warning-option
-Werror=unused-command-line-argument -no-pie` -> 0
> stderr:
> clang: warning: argument unused during compilation: '-no-pie'
[-Wunused-command-line-argument]
> -----------
> Compiler for C supports arguments -no-pie: YES
It seems there's a related issue thread on the Meson repository [1].
[1] https://github.com/mesonbuild/meson/issues/5355
> My suggestion is (if possible) to split out the parts of this series
> that are enough to run QEMU under TCI, and get those in as quickly as
> possible. The TCG backend can come second.
Sure, I'll try to split this patch series.
© 2016 - 2025 Red Hat, Inc.