From 987cca7bca559295e69bc4c34f76651732fd4c8f Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Wed, 19 Jun 2019 15:54:48 +1000 Subject: wasm: allow setting total memory for non thread builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using WASM_OBJECT_FILES does not allow memory growth, so we need to just explicitly check for QMAKE_WASM_TOTAL_MEMORY Change-Id: I447113972dfc3df4ee4073e8cc25481646d1507b Reviewed-by: Morten Johan Sørvig --- mkspecs/features/wasm/wasm.prf | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'mkspecs/features/wasm/wasm.prf') diff --git a/mkspecs/features/wasm/wasm.prf b/mkspecs/features/wasm/wasm.prf index 54d351bfd5..25413d7470 100644 --- a/mkspecs/features/wasm/wasm.prf +++ b/mkspecs/features/wasm/wasm.prf @@ -6,16 +6,6 @@ exists($$QMAKE_QT_CONFIG) { qtConfig(thread) { EMCC_THREAD_LFLAGS += -s USE_PTHREADS=1 - # Hardcode wasm memory size. Emscripten does not currently support memory growth - # (ALLOW_MEMORY_GROWTH) in pthreads mode, and requires specifying the memory size - # at build time. Further, browsers limit the maximum initial memory size to 1GB. - TOTAL_MEMORY = 1GB - !isEmpty(QMAKE_WASM_TOTAL_MEMORY) { - TOTAL_MEMORY = $$QMAKE_WASM_TOTAL_MEMORY - } - - message("Setting TOTAL_MEMORY to" $$TOTAL_MEMORY) - EMCC_THREAD_LFLAGS += -s TOTAL_MEMORY=$$TOTAL_MEMORY # Create worker threads at startup. This is supposed to be an optimization, # however exceeding the pool size has been obesverved to hang the application. @@ -29,6 +19,20 @@ exists($$QMAKE_QT_CONFIG) { } else { EMCC_THREAD_LFLAGS += -s ALLOW_MEMORY_GROWTH=1 } + + qtConfig(thread) | !isEmpty(QMAKE_WASM_TOTAL_MEMORY) { + + # Hardcode wasm memory size. Emscripten does not currently support memory growth + # (ALLOW_MEMORY_GROWTH) in pthreads mode, and requires specifying the memory size + # at build time. Further, browsers limit the maximum initial memory size to 1GB. + # QMAKE_WASM_TOTAL_MEMORY must be a multiple of 64KB + TOTAL_MEMORY = 1GB + !isEmpty(QMAKE_WASM_TOTAL_MEMORY) { + TOTAL_MEMORY = $$QMAKE_WASM_TOTAL_MEMORY + } + message("Setting TOTAL_MEMORY to" $$TOTAL_MEMORY) + EMCC_THREAD_LFLAGS += -s TOTAL_MEMORY=$$TOTAL_MEMORY + } QMAKE_LFLAGS += $$EMCC_THREAD_LFLAGS QMAKE_LFLAGS_DEBUG += $$EMCC_THREAD_LFLAGS QMAKE_CFLAGS += $$EMCC_THREAD_LFLAGS -- cgit v1.2.3