@@ -50,9 +50,9 @@ genh = []
50
50
qapi_trace_events = []
51
51
52
52
bsd_oses = [' gnu/kfreebsd' , ' freebsd' , ' netbsd' , ' openbsd' , ' dragonfly' , ' darwin' ]
53
- supported_oses = [' windows' , ' freebsd' , ' netbsd' , ' openbsd' , ' darwin' , ' sunos' , ' linux' ]
53
+ supported_oses = [' windows' , ' freebsd' , ' netbsd' , ' openbsd' , ' darwin' , ' sunos' , ' linux' , ' emscripten ' ]
54
54
supported_cpus = [' ppc' , ' ppc64' , ' s390x' , ' riscv32' , ' riscv64' , ' x86' , ' x86_64' ,
55
- ' arm' , ' aarch64' , ' loongarch64' , ' mips' , ' mips64' , ' sparc64' ]
55
+ ' arm' , ' aarch64' , ' loongarch64' , ' mips' , ' mips64' , ' sparc64' , ' wasm32 ' ]
56
56
57
57
cpu = host_machine .cpu_family()
58
58
@@ -353,6 +353,8 @@ foreach lang : all_languages
353
353
# endif
354
354
#endif''' )
355
355
# ok
356
+ elif compiler.get_id() == ' emscripten'
357
+ # ok
356
358
else
357
359
error (' You either need GCC v7.4 or Clang v10.0 (or XCode Clang v15.0) to compile QEMU' )
358
360
endif
@@ -470,7 +472,10 @@ endif
470
472
# instead, we can't add -no-pie because it overrides -shared: the linker then
471
473
# tries to build an executable instead of a shared library and fails. So
472
474
# don't add -no-pie anywhere and cross fingers. :(
473
- if not get_option (' b_pie' )
475
+ #
476
+ # Emscripten doesn't support -no-pie but meson can't catch the compiler
477
+ # warning. So explicitly omit the flag for Emscripten.
478
+ if not get_option (' b_pie' ) and host_os != ' emscripten'
474
479
qemu_common_flags += cc.get_supported_arguments(' -fno-pie' , ' -no-pie' )
475
480
endif
476
481
@@ -514,6 +519,8 @@ ucontext_probe = '''
514
519
supported_backends = []
515
520
if host_os == ' windows'
516
521
supported_backends += [' windows' ]
522
+ elif host_os == ' emscripten'
523
+ supported_backends += [' wasm' ]
517
524
else
518
525
if host_os != ' darwin' and cc.links(ucontext_probe)
519
526
supported_backends += [' ucontext' ]
@@ -902,6 +909,10 @@ if get_option('tcg').allowed()
902
909
if not get_option (' tcg_interpreter' )
903
910
error (' Unsupported CPU @0@, try --enable-tcg-interpreter' .format(cpu))
904
911
endif
912
+ elif host_arch == ' wasm32'
913
+ if not get_option (' tcg_interpreter' )
914
+ error (' WebAssembly host requires --enable-tcg-interpreter' )
915
+ endif
905
916
elif get_option (' tcg_interpreter' )
906
917
warning (' Use of the TCG interpreter is not recommended on this host' )
907
918
warning (' architecture. There is a native TCG execution backend available' )
@@ -2962,7 +2973,9 @@ config_host_data.set('CONFIG_ATOMIC64', cc.links('''
2962
2973
return 0;
2963
2974
}''' , args : qemu_isa_flags))
2964
2975
2965
- has_int128_type = cc.compiles('''
2976
+ # has_int128_type is set to false on Emscripten to avoid errors by libffi
2977
+ # during runtime.
2978
+ has_int128_type = host_os != ' emscripten' and cc.compiles('''
2966
2979
__int128_t a;
2967
2980
__uint128_t b;
2968
2981
int main(void) { b = a; }''' )
@@ -3774,6 +3787,8 @@ if have_block
3774
3787
# os-win32.c does not
3775
3788
if host_os == ' windows'
3776
3789
system_ss.add(files (' os-win32.c' ))
3790
+ elif host_os == ' emscripten'
3791
+ blockdev_ss.add(files (' os-wasm.c' ))
3777
3792
else
3778
3793
blockdev_ss.add(files (' os-posix.c' ))
3779
3794
endif
@@ -4456,7 +4471,11 @@ subdir('scripts')
4456
4471
subdir (' tools' )
4457
4472
subdir (' pc-bios' )
4458
4473
subdir (' docs' )
4459
- subdir (' tests' )
4474
+ # Tests are disabled on emscripten because they rely on host features that aren't
4475
+ # supported by emscripten (e.g. fork and unix socket).
4476
+ if host_os != ' emscripten'
4477
+ subdir (' tests' )
4478
+ endif
4460
4479
if gtk.found()
4461
4480
subdir (' po' )
4462
4481
endif
0 commit comments