[WASM] Cannot find global function runtime.SystemLib

Referencing issue 6330 on Github

Issue:

I ran the setup scripts as Tianqi suggested in task_web_wasm.sh and when I do npm run test I get the following error stack:

root@mydocker:/usr/tvm/web# npm run test

> tvmjs@0.7.0 test /usr/tvm/web
> jest

 FAIL  tests/node/test_ndarray.js
  ● array copy

    RuntimeError: memory access out of bounds
        at wasm-function[123]:0x8c36
        at wasm-function[12]:0x19ec
        at wasm-function[442]:0x1d022
        at wasm-function[61]:0x5b11
        at wasm-function[234]:0xf17b
        at wasm-function[1097]:0x49318

      1630 | 	        const outPtr = stack.ptrFromOffset(outOffset);
      1631 | 	        stack.commitToWasmMemory(outOffset);
    > 1632 | 	        this.lib.checkCall(this.exports.TVMArrayAlloc(stack.ptrFromOffset(shapeOffset), shape.length, dtype.code, dtype.bits, dtype.lanes, ctx.deviceType, ctx.deviceId, outPtr));
           | 	                                        ^
      1633 | 	        const ret = new NDArray(this.memory.loadPointer(outPtr), false, this.lib);
      1634 | 	        this.lib.recycleCallStack(stack);
      1635 | 	        return ret;

      at Instance.empty (dist/tvmjs.bundle.js:1632:42)
      at testArrayCopy (tests/node/test_ndarray.js:37:15)
      at Object.<anonymous> (tests/node/test_ndarray.js:51:3)

 FAIL  tests/node/test_module_load.js
  ● Test suite failed to run

    Cannot find global function runtime.SystemLib

      833 |     this.lib.recycleCallStack(stack);
      834 |     if (handle == 0) {
    > 835 |       throw Error("Cannot find global function " + name);
          |             ^
      836 |     }
      837 |     const ret = this.makePackedFunc(handle);
      838 |     return ret;

      at Instance.getGlobalFunc (src/runtime.ts:835:13)
      at Instance.systemLib (src/runtime.ts:742:28)
      at Object.<anonymous> (tests/node/test_module_load.js:36:20)

 FAIL  tests/node/test_packed_func.js
  ● GetGlobal

    Cannot find global function testing.add_one

      833 |     this.lib.recycleCallStack(stack);
      834 |     if (handle == 0) {
    > 835 |       throw Error("Cannot find global function " + name);
          |             ^
      836 |     }
      837 |     const ret = this.makePackedFunc(handle);
      838 |     return ret;

      at Instance.getGlobalFunc (src/runtime.ts:835:13)
      at Object.<anonymous> (tests/node/test_packed_func.js:36:21)

  ● ReturnFunc

    Cannot find global function testing.echo

      833 |     this.lib.recycleCallStack(stack);
      834 |     if (handle == 0) {
    > 835 |       throw Error("Cannot find global function " + name);
          |             ^
      836 |     }
      837 |     const ret = this.makePackedFunc(handle);
      838 |     return ret;

      at Instance.getGlobalFunc (src/runtime.ts:835:13)
      at Object.<anonymous> (tests/node/test_packed_func.js:80:19)

  ● RegisterGlobal

    Cannot find global function runtime.SystemLib

      833 |     this.lib.recycleCallStack(stack);
      834 |     if (handle == 0) {
    > 835 |       throw Error("Cannot find global function " + name);
          |             ^
      836 |     }
      837 |     const ret = this.makePackedFunc(handle);
      838 |     return ret;

      at Instance.getGlobalFunc (src/runtime.ts:835:13)
      at Instance.systemLib (src/runtime.ts:742:28)
      at Object.<anonymous> (tests/node/test_packed_func.js:109:20)

Test Suites: 3 failed, 3 total
Tests:       4 failed, 4 total
Snapshots:   0 total
Time:        2.804 s

Env

EMSDK: 1.39.0
LLVM: 10.0.1 (LLVM 12 breaks make in tvm/web )
TVM Commit ID: 5046ff25