diff options
author | Lorn Potter <lorn.potter@gmail.com> | 2019-06-19 15:54:48 +1000 |
---|---|---|
committer | Lorn Potter <lorn.potter@gmail.com> | 2019-08-22 04:41:04 +1000 |
commit | 987cca7bca559295e69bc4c34f76651732fd4c8f (patch) | |
tree | 9e20c4409a874033cad4fc84476b7d165be4777c | |
parent | d5c684c3c3e34e71bf50bdf1bd90039598b58afc (diff) |
wasm: allow setting total memory for non thread builds
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 <morten.sorvig@qt.io>
-rw-r--r-- | mkspecs/features/wasm/wasm.prf | 24 |
1 files changed, 14 insertions, 10 deletions
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 |