Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Error in webassembly compilation



  • When I build my project in webassembly with Qt 5.13.0 and emscripten sdk 1.38.27-64bit I get a very very very long output that ends with this:

     (func $legalfunc$_llvm_bswap_i64 (; 47925 ;) (; has Stack IR ;) (param $0 i64) (result i64)
      (i64.or
       (i64.extend_i32_u
        (call $legalimport$_llvm_bswap_i64
         (i32.wrap_i64
          (local.get $0)
         )
         (i32.wrap_i64
          (i64.shr_u
           (local.get $0)
           (i64.const 32)
          )
         )
        )
       )
       (i64.shl
        (i64.extend_i32_u
         (call $getTempRet0)
        )
        (i64.const 32)
       )
      )
     )
    )
    Fatal: error in validating output
    shared:ERROR: '.../emsdk/clang/e1.38.27_64bit/binaryen/bin/asm2wasm ./Application.temp.asm.js --total-memory=16777216 --trap-mode=clamp -O3 --mem-init=./Application.js.mem --mem-base=1024 --wasm-only -o ./Application.wasm --mvp-features' failed (1)
    

    The last line being an error, any idea what's going wrong?



  • Trying to increase total memory as suggested here: https://github.com/WebAssembly/binaryen/issues/1968
    (It's done in .pro file by setting QMAKE_WASM_TOTAL_MEMORY variable)



  • QMAKE_WASM_TOTAL_MEMORY didn't change the value of total-memory option of asm2wasm trying it manually



  • Now getting LinkError: WebAssembly.instantiate(): memory import 732 is smaller than initial 16384, got 256 when I try to open my application in browser, it seems to be related to increasing TOTAL_MEMORY (https://github.com/emscripten-core/emscripten/issues/5069) I don't understand if I can't increase TOTAL_MEMORY why it's suggested in the other github thread I linked earlier.



  • It's working now, I had to manually add -s TOTAL_MEMORY=64MB to LFLAGS in Makefile. I hope I'll find a better way cause otherwise I have to do it after each qmake.

    I was able to run a big mobile application I wrote last year in webassembly, it's fantastic how it worked out of the box.



  • You can either update your Qt, or apply this patch to your Qt:
    https://codereview.qt-project.org/c/qt/qtbase/+/265523

    Then you can set the total memory in yoru .pro file using
    QMAKE_WASM_TOTAL_MEMORY



  • 5.13.1 is not released as an stable Qt version and I'm using 5.13.0 (latest stable version) so I applied the patch. Thanks!


Log in to reply