wasm: remove compiler and linker warnings
INITIAL_MEMORY and PTHREAD_POOL_SIZE are linker flags only USE_PTHREADS is both linker and compiler arguments. Also increase default INITIAL_MEMORY Pick-to: 6.3 Change-Id: Id1998efbf1d6de901f404db7e988f6cafd547a39 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
d0cae531e6
commit
d10b910e39
@ -9,8 +9,8 @@ exists($$QMAKE_QT_CONFIG) {
|
||||
|
||||
qtConfig(thread) {
|
||||
|
||||
EMCC_THREAD_LFLAGS += -pthread
|
||||
EMCC_THREAD_CFLAGS += -pthread
|
||||
EMCC_LFLAGS += -pthread
|
||||
EMCC_CFLAGS += -pthread
|
||||
|
||||
# Create worker threads at startup. This is supposed to be an optimization,
|
||||
# however exceeding the pool size has been obesverved to hang the application.
|
||||
@ -20,24 +20,30 @@ exists($$QMAKE_QT_CONFIG) {
|
||||
}
|
||||
|
||||
message("Setting PTHREAD_POOL_SIZE to" $$POOL_SIZE)
|
||||
EMCC_THREAD_LFLAGS += -s PTHREAD_POOL_SIZE=$$POOL_SIZE
|
||||
EMCC_LFLAGS += -s PTHREAD_POOL_SIZE=$$POOL_SIZE
|
||||
} else {
|
||||
EMCC_THREAD_LFLAGS += -s ALLOW_MEMORY_GROWTH=1
|
||||
EMCC_LFLAGS += -s ALLOW_MEMORY_GROWTH=1
|
||||
}
|
||||
|
||||
qtConfig(thread) | !isEmpty(QT_WASM_INITIAL_MEMORY) {
|
||||
isEmpty(QT_WASM_INITIAL_MEMORY) {
|
||||
# Hardcode wasm memory size.
|
||||
|
||||
# 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.
|
||||
# QT_WASM_INITIAL_MEMORY must be a multiple of 64KB
|
||||
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
|
||||
!isEmpty(QT_WASM_INITIAL_MEMORY) {
|
||||
INITIAL_MEMORY = $$QT_WASM_INITIAL_MEMORY
|
||||
}
|
||||
message("Setting INITIAL_MEMORY to" $$INITIAL_MEMORY)
|
||||
EMCC_THREAD_LFLAGS += -s INITIAL_MEMORY=$$INITIAL_MEMORY
|
||||
} else {
|
||||
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
|
||||
@ -46,10 +52,10 @@ exists($$QMAKE_QT_CONFIG) {
|
||||
QMAKE_LFLAGS_DEBUG += -msimd128 -msse -msse2
|
||||
}
|
||||
|
||||
QMAKE_LFLAGS += $$EMCC_THREAD_LFLAGS
|
||||
QMAKE_LFLAGS_DEBUG += $$EMCC_THREAD_LFLAGS
|
||||
QMAKE_CFLAGS += $$EMCC_THREAD_CFLAGS
|
||||
QMAKE_CXXFLAGS += $$EMCC_THREAD_CFLAGS
|
||||
QMAKE_LFLAGS += $$EMCC_LFLAGS
|
||||
QMAKE_LFLAGS_DEBUG += $$EMCC_LFLAGS
|
||||
QMAKE_CFLAGS += $$EMCC_CFLAGS
|
||||
QMAKE_CXXFLAGS += $$EMCC_CFLAGS
|
||||
}
|
||||
|
||||
# Create js and wasm files for applications
|
||||
|
@ -30,23 +30,25 @@ function(_qt_internal_wasm_add_target_helpers target)
|
||||
message(DEBUG "Setting PTHREAD_POOL_SIZE to ${POOL_SIZE} for ${target}")
|
||||
endif()
|
||||
|
||||
# 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.
|
||||
# QT_WASM_INITIAL_MEMORY must be a multiple of 64KB (i.e. 65536)
|
||||
# Hardcode wasm memory size.
|
||||
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 "20MB")
|
||||
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}")
|
||||
|
Loading…
Reference in New Issue
Block a user