wasm: set MAXIMUM_MEMORY to 4GB

This increases the maximum available memory from 2GB
(Emscritpten default) to 4GB, which is the 32-bit wasm
max.

Add QT_WASM_MAXIMUM_MEMORY qmake/cmake option for overriding.

Change-Id: I6257fc919a749412c4ba1e0f939996c6057ce314
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit c6d3b91549ceaafa81cbcedf243f798f1114a467)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Morten Sørvig 2023-10-23 22:29:44 +02:00 committed by Qt Cherry-pick Bot
parent 8e82b16587
commit d510bfa2df
3 changed files with 38 additions and 0 deletions

View File

@ -48,6 +48,12 @@ exists($$QMAKE_QT_CONFIG) {
INITIAL_MEMORY = $$QT_WASM_INITIAL_MEMORY INITIAL_MEMORY = $$QT_WASM_INITIAL_MEMORY
} }
EMCC_LFLAGS += -s INITIAL_MEMORY=$$INITIAL_MEMORY EMCC_LFLAGS += -s INITIAL_MEMORY=$$INITIAL_MEMORY
isEmpty(QT_WASM_MAXIMUM_MEMORY) {
MAXIMUM_MEMORY = 4GB # 32-bit max
} else {
MAXIMUM_MEMORY = $$QT_WASM_MAXIMUM_MEMORY
}
EMCC_LFLAGS += -s MAXIMUM_MEMORY=$$MAXIMUM_MEMORY
qtConfig(sse2) { qtConfig(sse2) {
QMAKE_CFLAGS += -O2 -msimd128 -msse -msse2 QMAKE_CFLAGS += -O2 -msimd128 -msse -msse2

View File

@ -91,6 +91,15 @@ function(_qt_internal_wasm_add_target_helpers target)
endif() endif()
target_link_options("${target}" PRIVATE "SHELL:-s INITIAL_MEMORY=${QT_WASM_INITIAL_MEMORY}") target_link_options("${target}" PRIVATE "SHELL:-s INITIAL_MEMORY=${QT_WASM_INITIAL_MEMORY}")
# Set maximum memory size, either from user setting or to 4GB (the 32-bit maximum)
get_target_property(_tmp_maximumMemory "${target}" QT_WASM_MAXIMUM_MEMORY)
if(_tmp_maximumMemory)
set(QT_WASM_MAXIMUM_MEMORY "${_tmp_maximumMemory}")
elseif(NOT DEFINED QT_WASM_MAXIMUM_MEMORY)
set(QT_WASM_MAXIMUM_MEMORY "4GB")
endif()
target_link_options("${target}" PRIVATE "SHELL:-s MAXIMUM_MEMORY=${QT_WASM_MAXIMUM_MEMORY}")
endif() endif()
endfunction() endfunction()

View File

@ -591,6 +591,29 @@ QT_WASM_INITIAL_MEMORY must be a multiple of 65536 bytes.
For more information, see \l{https://github.com/emscripten-core/emscripten/blob/main/src/settings.js}{Emscripten compiler settings}. For more information, see \l{https://github.com/emscripten-core/emscripten/blob/main/src/settings.js}{Emscripten compiler settings}.
*/ */
/*!
\page cmake-target-property-qt-wasm-maximum-memory.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
\title QT_WASM_MAXIMUM_MEMORY
\target cmake-target-property-QT_WASM_MAXIMUM_MEMORY
\summary {Internal WebAssembly maximum memory.}
\cmakepropertysince 6.7
\preliminarycmakeproperty
\cmakepropertywebassemblyonly
Specifies the maximum amount of memory the applicataion can use. Translates into
the Emscripten compiler setting of MAXIMUM_MEMORY. The default value
is 4GB, which is the maximum for 32-bit WebAssembly.
For more information, see \l{https://github.com/emscripten-core/emscripten/blob/main/src/settings.js}{Emscripten compiler settings}.
*/
/*! /*!
\page cmake-target-property-qt-ios-launch-screen.html \page cmake-target-property-qt-ios-launch-screen.html
\ingroup cmake-properties-qtcore \ingroup cmake-properties-qtcore