On Thu, Apr 10, 2025 at 2:24 PM Kohei Tokunaga <ktokunaga.m...@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


Reply via email to