diff --git a/cmake/QtWasmHelpers.cmake b/cmake/QtWasmHelpers.cmake index 198ebbff23..07de3751ef 100644 --- a/cmake/QtWasmHelpers.cmake +++ b/cmake/QtWasmHelpers.cmake @@ -35,10 +35,10 @@ function (qt_internal_setup_wasm_target_properties wasmTarget) if (QT_FEATURE_thread) target_compile_options("${wasmTarget}" INTERFACE "SHELL:-pthread") target_link_options("${wasmTarget}" INTERFACE "SHELL:-pthread") - else() - target_link_options("${wasmTarget}" INTERFACE "SHELL:-s ALLOW_MEMORY_GROWTH=1") endif() + target_link_options("${wasmTarget}" INTERFACE "SHELL:-s ALLOW_MEMORY_GROWTH") + # debug add_compile_options if ("QT_WASM_SOURCE_MAP=1" IN_LIST QT_QMAKE_DEVICE_OPTIONS) set(WASM_SOURCE_MAP_BASE "http://localhost:8000/") diff --git a/mkspecs/features/wasm/wasm.prf b/mkspecs/features/wasm/wasm.prf index 5e6501ed99..5b7dbaf493 100644 --- a/mkspecs/features/wasm/wasm.prf +++ b/mkspecs/features/wasm/wasm.prf @@ -29,29 +29,16 @@ exists($$QMAKE_QT_CONFIG) { message("Setting PTHREAD_POOL_SIZE to" $$POOL_SIZE) EMCC_LFLAGS += -s PTHREAD_POOL_SIZE=$$POOL_SIZE - } else { - EMCC_LFLAGS += -s ALLOW_MEMORY_GROWTH=1 } + # Set memory options + EMCC_LFLAGS += -sALLOW_MEMORY_GROWTH isEmpty(QT_WASM_INITIAL_MEMORY) { - # Hardcode wasm memory size. - - qtConfig(thread) { - # Pthreads and ALLOW_MEMORY_GROWTH can cause javascript wasm memory access to - # be slow. Instead, we specify the memory size - # at build time. Further, browsers limit the maximum initial memory size to 1GB. - # https://github.com/WebAssembly/design/issues/1271 - INITIAL_MEMORY = 1GB - } else { - INITIAL_MEMORY = 50MB # emscripten default is 16MB, we need slightly more - } + INITIAL_MEMORY = 50MB # emscripten default is 16MB, we need slightly more } else { - # QT_WASM_INITIAL_MEMORY must be a multiple of 64KB (i.e. 65536) INITIAL_MEMORY = $$QT_WASM_INITIAL_MEMORY - message("Setting INITIAL_MEMORY to" $$INITIAL_MEMORY) } EMCC_LFLAGS += -s INITIAL_MEMORY=$$INITIAL_MEMORY - message("Setting INITIAL_MEMORY to" $$INITIAL_MEMORY) qtConfig(sse2) { QMAKE_CFLAGS += -O2 -msimd128 -msse -msse2 diff --git a/src/corelib/Qt6WasmMacros.cmake b/src/corelib/Qt6WasmMacros.cmake index 59f69174db..379229bc6a 100644 --- a/src/corelib/Qt6WasmMacros.cmake +++ b/src/corelib/Qt6WasmMacros.cmake @@ -48,29 +48,14 @@ function(_qt_internal_wasm_add_target_helpers target) message(DEBUG "Setting PTHREAD_POOL_SIZE to ${POOL_SIZE} for ${target}") endif() - # Hardcode wasm memory size. + # Set initial memory size, either from user setting or to a minimum amount required by Qt. get_target_property(_tmp_initialMemory "${target}" QT_WASM_INITIAL_MEMORY) if(_tmp_initialMemory) set(QT_WASM_INITIAL_MEMORY "${_tmp_initialMemory}") elseif(NOT DEFINED QT_WASM_INITIAL_MEMORY) - if(QT_FEATURE_thread) - # Pthreads and ALLOW_MEMORY_GROWTH can cause javascript wasm memory access to - # be slow and having to update HEAP* views. Instead, we specify the memory size - # at build time. Further, browsers limit the maximum initial memory size to 1GB. - # https://github.com/WebAssembly/design/issues/1271 - set(QT_WASM_INITIAL_MEMORY "1GB") - else() - # emscripten default is 16MB, we need slightly more sometimes - set(QT_WASM_INITIAL_MEMORY "50MB") - endif() - endif() - - if(DEFINED QT_WASM_INITIAL_MEMORY) - # QT_WASM_INITIAL_MEMORY must be a multiple of 65536 - target_link_options("${target}" - PRIVATE "SHELL:-s INITIAL_MEMORY=${QT_WASM_INITIAL_MEMORY}") - message(DEBUG "-- Setting INITIAL_MEMORY to ${QT_WASM_INITIAL_MEMORY} for ${target}") + set(QT_WASM_INITIAL_MEMORY "50MB") endif() + target_link_options("${target}" PRIVATE "SHELL:-s INITIAL_MEMORY=${QT_WASM_INITIAL_MEMORY}") endif() endfunction()