Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible compiler bug for target wasm-gc #375

Open
gmlewis opened this issue Dec 19, 2024 · 1 comment
Open

Possible compiler bug for target wasm-gc #375

gmlewis opened this issue Dec 19, 2024 · 1 comment

Comments

@gmlewis
Copy link
Contributor

gmlewis commented Dec 19, 2024

In this repo and directory:
https://github.com/gmlewis/modus/tree/add-moonbit-sdk/sdk/moonbit

I get this:

$ moon test --target wasm-gc
...

         --  --
       /  //  / __--------_
      /  //  /_/            \
   ---      -                \ __
  / X        /        ____   /   )
  *_________/__/_____/______/ `--

Oops, the compiler has encountered an unexpected situation.
This is a bug in the compiler.

A bug report containing the error description and relevant code would be
greatly appreciated. You can submit the bug report here:

  https://github.com/moonbitlang/moonbit-docs/issues/new?labels=bug,ICE

Error: Moonc.Basic_hash_string.Key_not_found("$moonbit.malloc")

Compiler args: moonc link-core /Users/glenn/.moon/lib/core/target/wasm-gc/release/bundle/core.core /Users/glenn/src/github.com/hypermodeinc/modus/sdk/moonbit/target/wasm-gc/debug/test/wit/ffi/ffi.core /Users/glenn/src/github.com/hypermodeinc/modus/sdk/moonbit/target/wasm-gc/debug/test/wit/interface/models/models.core /Users/glenn/src/github.com/hypermodeinc/modus/sdk/moonbit/target/wasm-gc/debug/test/wit/interface/console/console.core /Users/glenn/src/github.com/hypermodeinc/modus/sdk/moonbit/target/wasm-gc/debug/test/pkg/console/console.core /Users/glenn/src/github.com/hypermodeinc/modus/sdk/moonbit/target/wasm-gc/debug/test/pkg/models/models.core /Users/glenn/src/github.com/hypermodeinc/modus/sdk/moonbit/target/wasm-gc/debug/test/pkg/models/models.blackbox_test.core -main gmlewis/modus/pkg/models_blackbox_test -o /Users/glenn/src/github.com/hypermodeinc/modus/sdk/moonbit/target/wasm-gc/debug/test/pkg/models/models.blackbox_test.wasm -test-mode -pkg-config-path /Users/glenn/src/github.com/hypermodeinc/modus/sdk/moonbit/pkg/models/moon.pkg.json -pkg-sources gmlewis/modus/wit/ffi:/Users/glenn/src/github.com/hypermodeinc/modus/sdk/moonbit/wit/ffi -pkg-sources gmlewis/modus/wit/interface/models:/Users/glenn/src/github.com/hypermodeinc/modus/sdk/moonbit/wit/interface/models -pkg-sources gmlewis/modus/wit/interface/console:/Users/glenn/src/github.com/hypermodeinc/modus/sdk/moonbit/wit/interface/console -pkg-sources gmlewis/modus/pkg/console:/Users/glenn/src/github.com/hypermodeinc/modus/sdk/moonbit/pkg/console -pkg-sources gmlewis/modus/pkg/models:/Users/glenn/src/github.com/hypermodeinc/modus/sdk/moonbit/pkg/models -pkg-sources gmlewis/modus/pkg/models_blackbox_test:/Users/glenn/src/github.com/hypermodeinc/modus/sdk/moonbit/pkg/models -pkg-sources moonbitlang/core:/Users/glenn/.moon/lib/core -exported_functions moonbit_test_driver_internal_execute,moonbit_test_driver_finish -target wasm-gc -g -O0

moonc version: v0.1.20241218+f4a066f5f
error: failed to run test for target WasmGC

Caused by:
    failed when testing

$ moon test --target wasm
[============================----------  ] 45/64 done, 12/16 running
link-core: gmlewis/modus/wit/interface/graphqlClient_internal_test
link-core: gmlewis/modus/wit/pkg_internal_test
link-core: gmlewis/modus/wit/interface/dgraphClient_internal_test
link-core: gmlewis/modus/wit/interface/httpClient_internal_test
link-core: gmlewis/modus/wit/interface/sqlClient_internal_test
link-core: gmlewis/modus/wit/interface/models_internal_test
TypeError: WebAssembly.Instance(): Import #3 "modus_models": module is not an object or function
Failed to run the test: /Users/glenn/src/github.com/hypermodeinc/modus/sdk/moonbit/target/wasm/debug/test/pkg/models/models.blackbox_test.wasm

Total tests: 25, passed: 24, failed: 1.

The --target wasm problem is probably a bug in my code, but I thought you would be interested in the --target wasm-gc one above.

@peter-jerry-ye
Copy link
Collaborator

First of all, thank you for adding support to modus!

The $moonbit.malloc is an internal function used by wasm linear to allocate memory, which is of course absent in wasm-gc. I think you can check out tonyfettes/memory as @tonyfettes has implemented support for both wasm backend and wasm-gc backend.

With that said, modus uses wazero, which does not have gc support yet. Same applies to component model, and that's why I didn't bother implement for the wasm-gc backend. I think you need to stick to the wasm backend for now.

Of course, we shouldn't just crash when an inline function is absent @myfreess @Guest0x0 . We'll see how we can improve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants