Go with Emscripten’s default of not shutting down on
main() exit; this allows for writing main() in such
a way that avoids the exec() workaround.
Existing main() implementations (which do use the exec()
workaround) do not shut down Qt cleanly anyway, so we
gain little by shutting down the Emscripten runtime.
Applications can set this flag if they do want to shut
down on main() exit:
LFAGS += -s EXIT_RUNTIME=1
Change-Id: I52e1cc2bc907d1d2146822713e39b7610db3f95b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Make Emscripten generate a global constructor function
("createQtAppInstance()") instead of a global javascript
module object.
This enables more fine-grained control over module
instantiation; previously the module object would be
created when the runtime javascript was evaluated, and
the number of emscripten module/instances was limited
to one per page.
Set EXPORT_NAME to “createQtAppInstance” which avoids
collisions with other non-Qt Emscripten modules on
the same page. A further improvement would be to include
the app name in EXPORT_NAME, but this is not done at
this time.
Update the code in qtloader.js to call the constructor
function instead of working on a global module object.
The qtloader.js API is functional before the wasm and
Emscripten modules have been instantiated; store properties
and forward to the Emscripten module when it's created.
Change-Id: I12c49a5b9a4a932bbc46fcc5e5ecc453fd0fe7f0
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This fixes the "Command line is too long" error when building a project
with many object files for WASM on Windows.
Fixes: QTBUG-94032
Pick-to: 6.2 6.1 5.15
Change-Id: I29251da9795b267c968da86617da0311bf882a64
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
A few configure defines get changed:
QMAKE_WASM_PTHREAD_POOL_SIZE is now QT_WASM_PTHREAD_POOL_SIZE
QMAKE_WASM_TOTAL_MEMORY is now QT_WASM_INITIAL_MEMORY
QMAKE_WASM_SOURCE_MAP_BASE is now QT_WASM_SOURCE_MAP_BASE
device-option EMSCRIPTEN_ASYNCIFY=1 is QT_EMSCRIPTEN_ASYNCIFY=1
To create source maps for debugging. use
device-option QT_WASM_SOURCE_MAP=1
Task-number: QTBUG-78647
Change-Id: If9f30cd7fb408c386d6d69b5f7b1beecf1ab44b5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This also fixes source maps not getting created in debug mode.
Pick-to: 5.15
Fixes: QTBUG-83607
Change-Id: I3ed388c4fef6c286fa452a1c700fa65c2a8f9529
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Get rid of double negation to make the configuration easier to understand.
Change-Id: I5dfe256c2ac2ef131c3db20dce9ff492c529a5b1
Reference: https://emscripten.org/docs/tools_reference/emcc.html
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
./configure […] --device-option EMSCRIPTEN_ASYNCIFY=1
Set QT_HAVE_EMSCRIPTEN_ASYNCIFY as a feature flag,
enable optimizations for asyncified debug builds.
Change-Id: I81c887a411780e328aed48ec09ff6b9277c3bccf
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
On emsdk 13.9.x WASM_OBJECTS_FILES is always on,
and BINARYEN_TRAP_MODE is not needed
Change-Id: Id1da1db0278e131f95045bc0902f5cc4c22c1522
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This has better support for threaded use, and gets rid of bind use.
This requires emscripten 1.38.37 and above
Task-number: QTBUG-76891
Change-Id: Ic30a6820c2ce945c314751c06cfc356914a71217
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This reverts commit bcdf49bcc6.
This was a 5.14-only commit which accidentally found its
way to 5.15.
Change-Id: Iaef6f05fce20ab61d3afb8cb3c359a037e4c0b28
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Keep using the old/deprecated behavior for the Qt 5.14
series.
Task-number: QTBUG-74601
Change-Id: Icee99803f300dfa0116a4de75f9fb26d1010625d
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
As of version 1.39, Emscripten now uses upstream llvm instead of
the "fastcomp" fork. As a result of this em++ no longer builds
via the asm.js text format, and the performance issues related
to text parsing are gone.
Reducing the binary size for debug builds is no longer needed,
and we can fall back to using the default build flags.
This effectively makes 1.39.x the minimum Emscripten version for
Qt 5.15. The "-fastcomp" SDK variant is not supported.
Change-Id: Id66ef77294a9accd1b103e34785458d71dc188b1
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Avoid redundant conversions from UTF16 to UTF8 to UTF16 with
help of new class QWasmString static methods:
+ QWasmString::fromQString to convert QString to js string
using js Module.UTF16ToString
+ QWasmString::toQString to convert js string to QString
using js Module.stringToUTF16
Fixed document.getElementById calls for cavasId with unicode characters.
Change-Id: I3fc55bfeb6aeda75fa3acd85d22cea667b542f38
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Emscripten version 1.39.0 and above are based upon upstream LLVM, which
does not contain BINARYEN_TRAP_MODE
Fixes: QTBUG-80691
Change-Id: I6129f84a31a607c202e13847b50705ef1c809630
Reviewed-by: jian liang <jianliang79@gmail.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Clamp mode was being obliterated by not appending to EMCC_COMMON_LFLAGS
This fixes crashes of integer overflow
Change-Id: Icae757a7189de25db5ed41df6d41d86304c39830
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Our WebGL 2 support is half finished, since we use surface format verion of 3
to map to webgl2, but do not enable Open GL ES3 needed for WebGL2 support.
This allows glDrawArrays and glDrawElements to be used
Change-Id: Ifbd434f4d25e49f671145a6727999a90920d6810
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
If qmake is called without sh.exe in PATH, the relative paths
in OBJECTS will contain backslashes as separator.
Anyhow, emar needs forward slashes. Use GNU make's subst command
to fix this.
This amends 22c1e10e19.
Task-number: QTBUG-75257
Change-Id: Iacc6fe69cf470f35c6ddd829be7a80944346452d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
On Windows we hit the command line length limit when building the wasm
port of Qt. We must not pass the list of object files directly to emar,
but write a response file which is then passed via the @ parameter.
Fixes: QTBUG-75257
Change-Id: Id518fd81325716b8efaba29f495568a9a3e34be4
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Compilation breaks on Windows and macOS hosts with USE_ZLIB=1.
In addition, it turns out that the versions of the libraries in
Emscripten Ports are outdated. Since we have newer versions
of these libraries in Qt already, we will just use those.
This is a revert of 70b558ad5b.
Task-number: QTQAINFRA-2835
Change-Id: Ic2642b7d319a3447fd08843657eb0535255e0449
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This mode significantly improves build (link) time.
Opt-in by passing “-device-option WASM_OBJECT_FILES=1”
to configure.
This requires a custom emsdk build which uses upstream
llvm.
Task-number: QTBUG-72537
Change-Id: I47bab2b58ae7e49ca104233ec14fff7b93516d36
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This is a revert of eea08d376a.
We need these flags to be added to the compiler in order to find the
emscripten ports to be able to use them.
Task-number: QTBUG-73127
Change-Id: Icf70f456947aef04dc79b2328f2e95fb1e94fcf8
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
configure.json: Make the “thread” feature be allowed
for wasm but disabled by default.
Change qmake.conf and wasm.prf to enable Emscripten
pthreads mode:
- Add USE_PTHREADS=1 linker flag
- Add PTHREAD_POOL_SIZE linker flag with a default pool size (4).
- Add TOTAL_MEMORY linker flag to set available memory (1GB)
It is possible to override options such as PTHREAD_POOL_SIZE
from the application .pro file using QMAKE_WASM_PTHREAD_POOL_SIZE
To change TOTAL_MEMORY, use QMAKE_WASM_TOTAL_MEMORY
Make qtloader.js work in pthreads mode:
- The Module.instantiateWasm callback must provide the module
in addition to the instance to Emscripten.
- Set Module.mainScriptUrlOrBlob so that the pthreads web workers
can access the main script
Task-number: QTBUG-64625
Change-Id: I1ab5a559ec97c27c5fc24500ba5f863bcd275141
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This has been removed in emscripten compler version 1.38.23 and will
cause building apps to fail.
Change-Id: I7e58053ce06053f6f1d577377b503cabb035bb58
Fixes: QTBUG-73143
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
fix the plugin name (it was missing the leading 'q') and the name used
in configure (the latter making it unnecessary to mess with it in the
mkspec). the qt.prf override which forced linkage of the plugin is also
removed due to being completely redundant.
Change-Id: I94687a34a295c36754e36a298af902b656ba2ecc
Reviewed-by: Kyle Edwards <kyle.edwards@kitware.com>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
these libraries are handled by the configure system. i presume this to
be an artifact of an early version.
Change-Id: Ieee0554163a9fe296097d09e60a70719beee97b4
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This is the squashed diff from wip/webassembly to dev.
Done-with: Peng Wu <peng.wu@intopalo.com>
Done-with: Sami Enne <sami.enne@intopalo.com>
Done-with: Morten Johan Sørvig <morten.sorvig@qt.io>
Started-by: Andrew Knight <andrew.knight@intopalo.com>
Change-Id: I6562433c0a38d6ec49ab675e0f104f2665f3392d
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>