Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Error in webassembly compilation
Forum Updated to NodeBB v4.3 + New Features

Error in webassembly compilation

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 1.1k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sassanh
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sassanh
      wrote on last edited by
      #2

      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)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sassanh
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sassanh
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sassanh
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • lorn.potterL Offline
              lorn.potterL Offline
              lorn.potter
              wrote on last edited by lorn.potter
              #6

              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

              Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
              Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

              1 Reply Last reply
              3
              • S Offline
                S Offline
                sassanh
                wrote on last edited by
                #7

                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!

                1 Reply Last reply
                1

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved