Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-72537

webassembly: Support WASM_OBJECT_FILES=1


    • Type: Task
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: QPA: Other
    • Labels:
    • Platform/s:
    • Technical Risk:
    • Commits:
    • Epic Link:



      Enabling WASM_OBJECT_FILES=1 makes the compiler produce object files in the wasm format instead of llvm bitcode. This makes linking significantly faster, especially when not optimizing.

      Currently this requires building upstream llvm/clang from source, instead of using the "fastcomp" fork shipped with emsdk. This mode will eventually be the default for emscripten.

      Known/encountered issues:

      • wasm-opt crash:
         shared:ERROR: '/Users/msorvig/dev/binaryen/bin/wasm-opt ./gui_opengl.wasm.pre -o ./gui_opengl.wasm -O3' failed (-10) 

        (work around by building with -O0)

      • Computed goto is not supported: the QML compiler does not build.
        qv4instr_moth.cpp:175:6: error: WebAssembly
              hasn't implemented computed gotos 
      • Warnings (mostly harmless?):
        wasm-ld: warning: function signature mismatch: _ZNK20QPlatformIntegration12possibleKeysEPK9QKeyEvent
        >>> defined as () -> void in /Users/msorvig/code/qt-webassembly-stock-llvm/qt-webassembly-build-wasm/qtbase/plugins/platforms/libqwasm.a(moc_qwasmintegration.o)
        >>> defined as (i32, i32, i32) -> void in /Users/msorvig/code/qt-webassembly-stock-llvm/qt-webassembly-build-wasm/qtbase/lib/libQt5Gui.a(qplatformintegration.o)

      Getting started:

      (Note: this is "how-I-did-it", not necessarily "how-it-should-be-done".)

      1. Clone the following repositories:

      2. Check out the version you want to use

      • emscripten and binaryen have matching emsdk version tags, for example "1.38.23".
      • llvm has its own version numbers, and must be synced up manually. Currently:
        • emscripten <= 1.38.23 : llvm 8.0 (8.0.0-rc2 branch)
        • emscripten > 1.38.23 : llvm 9.0 (master branch)
          (em++/emcc will complain if you have the incorrect llvm version)

      3. Build

      • emscripten is all python, no build needed.
      • binaryen: "cmake -GNinja && ninja"
      • llvm:
        cmake -GNinja

        (one of the WebAssembly targets may be redundant)

      3. Configure Environment

      I use the following:

      export EMSDK="/Users/msorvig/dev/emsdks/emscripten-1.38.23"
      export PATH="$EMSDK:$PATH"
      export LLVM="/Users/msorvig/dev/emsdks/llvm-8.0.0-build/bin"
      export BINARYEN="/Users/msorvig/dev/emsdks/binaryen-1.38.23"
      export EM_CONFIG="/Users/msorvig/dev/emsdks/.emscripten-vanillallvm-1.38.23"
      export EM_CACHE="/Users/msorvig/dev/emsdks/.emscripten-vanillallvm-cache-1.38.23"

      Where .emscripten-vanillallvm-1.38.23 is a copy of the .emscripten config file that emsdk generates.


        No reviews matched the request. Check your Options in the drop-down menu of this sections header.



            • Assignee:
              sorvig Morten Sørvig
              sorvig Morten Sørvig
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created:

                Gerrit Reviews

                There are no open Gerrit changes