mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
meson: Add wasm build in build scripts
has_int128_type is set to false on emscripten as of now to avoid errors by libffi. Tests are disabled on emscripten because they rely on host features that aren't supported by emscripten (e.g. fork and unix socket). Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com> Link: https://lore.kernel.org/r/ad03b3b180335f59e785e930968077bf15c46260.1745820062.git.ktokunaga.mail@gmail.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
5b78d120ff
commit
ccc403ed58
6 changed files with 42 additions and 7 deletions
|
@ -634,6 +634,7 @@ S: Maintained
|
||||||
F: include/system/os-wasm.h
|
F: include/system/os-wasm.h
|
||||||
F: os-wasm.c
|
F: os-wasm.c
|
||||||
F: util/coroutine-wasm.c
|
F: util/coroutine-wasm.c
|
||||||
|
F: configs/meson/emscripten.txt
|
||||||
|
|
||||||
Alpha Machines
|
Alpha Machines
|
||||||
--------------
|
--------------
|
||||||
|
|
8
configs/meson/emscripten.txt
Normal file
8
configs/meson/emscripten.txt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[built-in options]
|
||||||
|
c_args = ['-pthread']
|
||||||
|
cpp_args = ['-pthread']
|
||||||
|
objc_args = ['-pthread']
|
||||||
|
# -sPROXY_TO_PTHREAD link time flag always requires -pthread even during
|
||||||
|
# configuration so explicitly add the flag here.
|
||||||
|
c_link_args = ['-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 = ['-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']
|
7
configure
vendored
7
configure
vendored
|
@ -360,6 +360,10 @@ elif check_define __NetBSD__; then
|
||||||
host_os=netbsd
|
host_os=netbsd
|
||||||
elif check_define __APPLE__; then
|
elif check_define __APPLE__; then
|
||||||
host_os=darwin
|
host_os=darwin
|
||||||
|
elif check_define EMSCRIPTEN ; then
|
||||||
|
host_os=emscripten
|
||||||
|
cpu=wasm32
|
||||||
|
cross_compile="yes"
|
||||||
else
|
else
|
||||||
# This is a fatal error, but don't report it yet, because we
|
# 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
|
# might be going to just print the --help text, or it might
|
||||||
|
@ -526,6 +530,9 @@ case "$cpu" in
|
||||||
linux_arch=x86
|
linux_arch=x86
|
||||||
CPU_CFLAGS="-m64"
|
CPU_CFLAGS="-m64"
|
||||||
;;
|
;;
|
||||||
|
wasm32)
|
||||||
|
CPU_CFLAGS="-m32"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if test -n "$host_arch" && {
|
if test -n "$host_arch" && {
|
||||||
|
|
27
meson.build
27
meson.build
|
@ -50,9 +50,9 @@ genh = []
|
||||||
qapi_trace_events = []
|
qapi_trace_events = []
|
||||||
|
|
||||||
bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin']
|
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',
|
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()
|
cpu = host_machine.cpu_family()
|
||||||
|
|
||||||
|
@ -353,6 +353,8 @@ foreach lang : all_languages
|
||||||
# endif
|
# endif
|
||||||
#endif''')
|
#endif''')
|
||||||
# ok
|
# ok
|
||||||
|
elif compiler.get_id() == 'emscripten'
|
||||||
|
# ok
|
||||||
else
|
else
|
||||||
error('You either need GCC v7.4 or Clang v10.0 (or XCode Clang v15.0) to compile QEMU')
|
error('You either need GCC v7.4 or Clang v10.0 (or XCode Clang v15.0) to compile QEMU')
|
||||||
endif
|
endif
|
||||||
|
@ -470,7 +472,10 @@ endif
|
||||||
# instead, we can't add -no-pie because it overrides -shared: the linker then
|
# instead, we can't add -no-pie because it overrides -shared: the linker then
|
||||||
# tries to build an executable instead of a shared library and fails. So
|
# tries to build an executable instead of a shared library and fails. So
|
||||||
# don't add -no-pie anywhere and cross fingers. :(
|
# don't add -no-pie anywhere and cross fingers. :(
|
||||||
if not get_option('b_pie')
|
#
|
||||||
|
# Emscripten doesn't support -no-pie but meson can't catch the compiler
|
||||||
|
# warning. So explicitly omit the flag for Emscripten.
|
||||||
|
if not get_option('b_pie') and host_os != 'emscripten'
|
||||||
qemu_common_flags += cc.get_supported_arguments('-fno-pie', '-no-pie')
|
qemu_common_flags += cc.get_supported_arguments('-fno-pie', '-no-pie')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -514,6 +519,8 @@ ucontext_probe = '''
|
||||||
supported_backends = []
|
supported_backends = []
|
||||||
if host_os == 'windows'
|
if host_os == 'windows'
|
||||||
supported_backends += ['windows']
|
supported_backends += ['windows']
|
||||||
|
elif host_os == 'emscripten'
|
||||||
|
supported_backends += ['wasm']
|
||||||
else
|
else
|
||||||
if host_os != 'darwin' and cc.links(ucontext_probe)
|
if host_os != 'darwin' and cc.links(ucontext_probe)
|
||||||
supported_backends += ['ucontext']
|
supported_backends += ['ucontext']
|
||||||
|
@ -902,6 +909,10 @@ if get_option('tcg').allowed()
|
||||||
if not get_option('tcg_interpreter')
|
if not get_option('tcg_interpreter')
|
||||||
error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
|
error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
|
||||||
endif
|
endif
|
||||||
|
elif host_arch == 'wasm32'
|
||||||
|
if not get_option('tcg_interpreter')
|
||||||
|
error('WebAssembly host requires --enable-tcg-interpreter')
|
||||||
|
endif
|
||||||
elif get_option('tcg_interpreter')
|
elif get_option('tcg_interpreter')
|
||||||
warning('Use of the TCG interpreter is not recommended on this host')
|
warning('Use of the TCG interpreter is not recommended on this host')
|
||||||
warning('architecture. There is a native TCG execution backend available')
|
warning('architecture. There is a native TCG execution backend available')
|
||||||
|
@ -2962,7 +2973,9 @@ config_host_data.set('CONFIG_ATOMIC64', cc.links('''
|
||||||
return 0;
|
return 0;
|
||||||
}''', args: qemu_isa_flags))
|
}''', args: qemu_isa_flags))
|
||||||
|
|
||||||
has_int128_type = cc.compiles('''
|
# has_int128_type is set to false on Emscripten to avoid errors by libffi
|
||||||
|
# during runtime.
|
||||||
|
has_int128_type = host_os != 'emscripten' and cc.compiles('''
|
||||||
__int128_t a;
|
__int128_t a;
|
||||||
__uint128_t b;
|
__uint128_t b;
|
||||||
int main(void) { b = a; }''')
|
int main(void) { b = a; }''')
|
||||||
|
@ -3775,6 +3788,8 @@ if have_block
|
||||||
# os-win32.c does not
|
# os-win32.c does not
|
||||||
if host_os == 'windows'
|
if host_os == 'windows'
|
||||||
system_ss.add(files('os-win32.c'))
|
system_ss.add(files('os-win32.c'))
|
||||||
|
elif host_os == 'emscripten'
|
||||||
|
blockdev_ss.add(files('os-wasm.c'))
|
||||||
else
|
else
|
||||||
blockdev_ss.add(files('os-posix.c'))
|
blockdev_ss.add(files('os-posix.c'))
|
||||||
endif
|
endif
|
||||||
|
@ -4516,7 +4531,11 @@ subdir('scripts')
|
||||||
subdir('tools')
|
subdir('tools')
|
||||||
subdir('pc-bios')
|
subdir('pc-bios')
|
||||||
subdir('docs')
|
subdir('docs')
|
||||||
|
# Tests are disabled on emscripten because they rely on host features that aren't
|
||||||
|
# supported by emscripten (e.g. fork and unix socket).
|
||||||
|
if host_os != 'emscripten'
|
||||||
subdir('tests')
|
subdir('tests')
|
||||||
|
endif
|
||||||
if gtk.found()
|
if gtk.found()
|
||||||
subdir('po')
|
subdir('po')
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -34,7 +34,7 @@ option('fuzzing_engine', type : 'string', value : '',
|
||||||
option('trace_file', type: 'string', value: 'trace',
|
option('trace_file', type: 'string', value: 'trace',
|
||||||
description: 'Trace file prefix for simple backend')
|
description: 'Trace file prefix for simple backend')
|
||||||
option('coroutine_backend', type: 'combo',
|
option('coroutine_backend', type: 'combo',
|
||||||
choices: ['ucontext', 'sigaltstack', 'windows', 'auto'],
|
choices: ['ucontext', 'sigaltstack', 'windows', 'wasm', 'auto'],
|
||||||
value: 'auto', description: 'coroutine backend to use')
|
value: 'auto', description: 'coroutine backend to use')
|
||||||
|
|
||||||
# Everything else can be set via --enable/--disable-* option
|
# Everything else can be set via --enable/--disable-* option
|
||||||
|
|
|
@ -80,7 +80,7 @@ meson_options_help() {
|
||||||
printf "%s\n" ' --tls-priority=VALUE Default TLS protocol/cipher priority string'
|
printf "%s\n" ' --tls-priority=VALUE Default TLS protocol/cipher priority string'
|
||||||
printf "%s\n" ' [NORMAL]'
|
printf "%s\n" ' [NORMAL]'
|
||||||
printf "%s\n" ' --with-coroutine=CHOICE coroutine backend to use (choices:'
|
printf "%s\n" ' --with-coroutine=CHOICE coroutine backend to use (choices:'
|
||||||
printf "%s\n" ' auto/sigaltstack/ucontext/windows)'
|
printf "%s\n" ' auto/sigaltstack/ucontext/windows/wasm)'
|
||||||
printf "%s\n" ' --with-pkgversion=VALUE use specified string as sub-version of the'
|
printf "%s\n" ' --with-pkgversion=VALUE use specified string as sub-version of the'
|
||||||
printf "%s\n" ' package'
|
printf "%s\n" ' package'
|
||||||
printf "%s\n" ' --with-suffix=VALUE Suffix for QEMU data/modules/config directories'
|
printf "%s\n" ' --with-suffix=VALUE Suffix for QEMU data/modules/config directories'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue