Skip to content

Commit cb6510f

Browse files
committed
build(ITKWebAssemblyInterface): set all required flags
These do not seem to be reliably picked up from the environmental variables anymore.
1 parent 4b63124 commit cb6510f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/docker/itk-wasm/ITKWebAssemblyInterface.cmake

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ function(add_executable target)
4040
set(wasm_target ${target})
4141
_add_executable(${wasm_target} ${ARGN})
4242
# Suppress CLI11 Encoding_inl.hpp std::wstring_convert deprecation warning
43-
set_property(TARGET ${wasm_target} APPEND PROPERTY COMPILE_OPTIONS "-Wno-deprecated-declarations")
43+
set_property(TARGET ${wasm_target} APPEND PROPERTY COMPILE_OPTIONS -msimd128 -flto -Wno-warn-absolute-paths -Wno-deprecated-declarations -DITK_WASM_NO_FILESYSTEM_IO)
4444
if(EMSCRIPTEN)
4545
kebab_to_camel(${target} targetCamel)
4646
get_property(_link_flags TARGET ${target} PROPERTY LINK_FLAGS)
47-
set(common_link_flags " -s FORCE_FILESYSTEM=1 -s
48-
EXPORTED_RUNTIME_METHODS='[\"callMain\",\"cwrap\",\"ccall\",\"writeArrayToMemory\",\"lengthBytesUTF8\",\"stringToUTF8\",\"UTF8ToString\", \"stackSave\", \"stackRestore\"]' -flto -s ALLOW_MEMORY_GROWTH=1 -s MAXIMUM_MEMORY=4GB -s WASM=1 -lnodefs.js -s WASM_ASYNC_COMPILATION=1 -s EXPORT_NAME=${targetCamel} -s MODULARIZE=1 -s EXIT_RUNTIME=0 -s INVOKE_RUN=0 --pre-js /ITKWebAssemblyInterface/src/emscripten-module/itkJSPipelinePre.js --post-js /ITKWebAssemblyInterface/src/emscripten-module/itkJSPost.js -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s EXPORTED_FUNCTIONS='[\"_main\"]' ${_link_flags}")
47+
set(common_link_flags "-flto -s ALLOW_MEMORY_GROWTH=1 -s MAXIMUM_MEMORY=4GB -s FORCE_FILESYSTEM=1 -s EXPORTED_RUNTIME_METHODS='[\"callMain\",\"cwrap\",\"ccall\",\"writeArrayToMemory\",\"lengthBytesUTF8\",\"stringToUTF8\",\"UTF8ToString\", \"stackSave\", \"stackRestore\"]' -flto -s ALLOW_MEMORY_GROWTH=1 -s MAXIMUM_MEMORY=4GB -s WASM=1 -lnodefs.js -s WASM_ASYNC_COMPILATION=1 -s EXPORT_NAME=${targetCamel} -s MODULARIZE=1 -s EXIT_RUNTIME=0 -s INVOKE_RUN=0 --pre-js /ITKWebAssemblyInterface/src/emscripten-module/itkJSPipelinePre.js --post-js /ITKWebAssemblyInterface/src/emscripten-module/itkJSPost.js -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s EXPORTED_FUNCTIONS='[\"_main\"]' ${_link_flags}")
4948
set_property(TARGET ${wasm_target} PROPERTY LINK_FLAGS "${common_link_flags} -s EXPORT_ES6=1 -s USE_ES6_IMPORT_META=1")
5049

5150
get_property(_include_dirs TARGET ${target} PROPERTY INCLUDE_DIRECTORIES)
@@ -75,9 +74,13 @@ function(add_executable target)
7574
get_property(_is_imported TARGET ${wasm_target} PROPERTY IMPORTED)
7675
if (NOT ${_is_imported})
7776
_target_link_libraries(${target} PRIVATE $<$<LINK_LANGUAGE:CXX>:wasi-itk-extras>)
77+
set_property(TARGET ${wasm_target} APPEND PROPERTY COMPILE_OPTIONS -flto -msimd128 -D_WASI_EMULATED_PROCESS_CLOCKS -D_WASI_EMULATED_SIGNAL)
78+
target_compile_options(${wasm_target} PRIVATE $<$<CONFIG:Debug>:-fno-lto -g>)
7879
get_property(_link_flags TARGET ${wasm_target} PROPERTY LINK_FLAGS)
7980
set_property(TARGET ${wasm_target} PROPERTY LINK_FLAGS
80-
"-mexec-model=reactor -Wl,--export-if-defined=itk_wasm_input_array_alloc -Wl,--export-if-defined=itk_wasm_input_json_alloc -Wl,--export-if-defined=itk_wasm_output_json_address -Wl,--export-if-defined=itk_wasm_output_json_size -Wl,--export-if-defined=itk_wasm_output_array_address -Wl,--export-if-defined=itk_wasm_output_array_size -Wl,--export-if-defined=itk_wasm_free_all -Wl,--export-if-defined=_start -Wl,--export-if-defined=itk_wasm_delayed_start -Wl,--export-if-defined=itk_wasm_delayed_exit ${_link_flags}")
81+
"-flto -lwasi-emulated-process-clocks -lwasi-emulated-signal -lc-printscan-long-double -mexec-model=reactor -Wl,--export-if-defined=itk_wasm_input_array_alloc -Wl,--export-if-defined=itk_wasm_input_json_alloc -Wl,--export-if-defined=itk_wasm_output_json_address -Wl,--export-if-defined=itk_wasm_output_json_size -Wl,--export-if-defined=itk_wasm_output_array_address -Wl,--export-if-defined=itk_wasm_output_array_size -Wl,--export-if-defined=itk_wasm_free_all -Wl,--export-if-defined=_start -Wl,--export-if-defined=itk_wasm_delayed_start -Wl,--export-if-defined=itk_wasm_delayed_exit ${_link_flags}")
82+
set_property(TARGET ${wasm_target} PROPERTY LINK_FLAGS_DEBUG
83+
"-fno-lto -lwasi-emulated-process-clocks -lwasi-emulated-signal -lc-printscan-long-double -mexec-model=reactor -Wl,--export-if-defined=itk_wasm_input_array_alloc -Wl,--export-if-defined=itk_wasm_input_json_alloc -Wl,--export-if-defined=itk_wasm_output_json_address -Wl,--export-if-defined=itk_wasm_output_json_size -Wl,--export-if-defined=itk_wasm_output_array_address -Wl,--export-if-defined=itk_wasm_output_array_size -Wl,--export-if-defined=itk_wasm_free_all -Wl,--export-if-defined=_start -Wl,--export-if-defined=itk_wasm_delayed_start -Wl,--export-if-defined=itk_wasm_delayed_exit ${_link_flags}")
8184
if(NOT ITK_WASM_NO_INTERFACE_LINK)
8285
if(NOT TARGET WebAssemblyInterface)
8386
find_package(ITK QUIET COMPONENTS WebAssemblyInterface)

0 commit comments

Comments
 (0)