Skip to content

Commit eac7bfb

Browse files
committed
meson.build: Propagate optimization flag for linking on Emscripten
Emscripten uses the optimization flag at the 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.mail@gmail.com>
1 parent d12537f commit eac7bfb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

meson.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,12 @@ elif host_os == 'openbsd'
878878
# Disable OpenBSD W^X if available
879879
emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
880880
endif
881+
elif host_os == 'emscripten'
882+
# Emscripten uses the optimization flag also during the link time.
883+
# https://emscripten.org/docs/optimizing/Optimizing-Code.html#how-emscripten-optimizes
884+
if get_option('optimization') != 'plain'
885+
emulator_link_args += ['-O' + get_option('optimization')]
886+
endif
881887
endif
882888

883889
###############################################

0 commit comments

Comments
 (0)