Emscripten uses the optimization flag at link time to enable optimizations via Binaryen [1]. While meson.build currently recognizes the -Doptimization option, it does not propagate it to the linking. This commit updates meson.build to propagate the optimization flag to the linking when targeting WebAssembly.
[1] https://emscripten.org/docs/optimizing/Optimizing-Code.html#how-emscripten-optimizes Signed-off-by: Kohei Tokunaga <ktokunaga.m...@gmail.com> --- meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meson.build b/meson.build index f6ed867819..91e182092d 100644 --- a/meson.build +++ b/meson.build @@ -869,6 +869,10 @@ elif host_os == 'openbsd' # Disable OpenBSD W^X if available emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded') endif +elif host_os == 'emscripten' + if get_option('optimization') != 'plain' + emulator_link_args += ['-O' + get_option('optimization')] + endif endif ############################################### -- 2.43.0