Skip to content

Commit

Permalink
wasm: set MAXIMUM_MEMORY to 4GB
Browse files Browse the repository at this point in the history
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.

Pick-to: 6.7
Change-Id: I6257fc919a749412c4ba1e0f939996c6057ce314
Reviewed-by: Morten Johan Sørvig <[email protected]>
  • Loading branch information
Morten Sørvig committed Dec 20, 2023
1 parent db93cd4 commit c6d3b91
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mkspecs/features/wasm/wasm.prf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ exists($$QMAKE_QT_CONFIG) {
INITIAL_MEMORY = $$QT_WASM_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) {
QMAKE_CFLAGS += -O2 -msimd128 -msse -msse2
Expand Down
9 changes: 9 additions & 0 deletions src/corelib/Qt6WasmMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ function(_qt_internal_wasm_add_target_helpers target)
endif()
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()
endfunction()

Expand Down
23 changes: 23 additions & 0 deletions src/corelib/doc/src/cmake/cmake-properties.qdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
*/

/*!
\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
\ingroup cmake-properties-qtcore
Expand Down

0 comments on commit c6d3b91

Please sign in to comment.