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

webassembly: Support WASM_OBJECT_FILES=1

    XMLWordPrintable

Details

    • Task
    • Resolution: Done
    • P3: Somewhat important
    • None
    • None
    • QPA
    • None

    Description

      Why

      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".)

      (Note the 2nd: See also v8.dev/blog for official instructions on how to install using emsdk)

      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
        ../path/to/llvmcheckout
        -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi;lld"
        -DCMAKE_BUILD_TYPE=Release
        -DLLVM_TARGETS_TO_BUILD=WebAssembly
        -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly
        

        (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.

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes