Odin icon indicating copy to clipboard operation
Odin copied to clipboard

`js_wasm32` default entry point fails to link

Open JimmyLefevre opened this issue 3 years ago • 1 comments

Context

Following the example from vendor/wasm with a stub Odin program:

package main
// Compile: odin build . -target=js_wasm32

main :: proc() {
}

@export step :: proc "c" () {
}

On Windows/Linux, Firefox.

Expected Behavior

The program should build and link properly.

Current Behavior

The program builds fine, but WebAssembly.instantiate returns a LinkError: import object field 'env..__$startup_runtime' is not a Function error.

Failure Information (for bugs)

It seems like this bug was introduced by https://github.com/odin-lang/Odin/commit/e15f71466005ff84c6dc97cbfbd10d57f1193e7a , which introduces the call to _startup_runtime, whose link name is __$startup_runtime.

Compiling with -no-entry-point and adding our own entry point fixes the issue:

package main
// Compile: odin build . -target=js_wasm32 -no-entry-point

import "core:runtime"

@export _start :: proc "c" () {
  context = runtime.default_allocator()
  main()
}

main :: proc() {
}

@export step :: proc "c" () {
}

JimmyLefevre avatar Feb 22 '22 17:02 JimmyLefevre

Hello!

I am marking this issue as stale as it has not received any engagement from the community or maintainers 120 days. That does not imply that the issue has no merit! If you feel strongly about this issue

  • open a PR referencing and resolving the issue;
  • leave a comment on it and discuss ideas how you could contribute towards resolving it;
  • leave a comment and describe in detail why this issue is critical for your use case;
  • open a new issue with updated details and a plan on resolving the issue.

The motivation for this automation is to help prioritize issues in the backlog and not ignore, reject, or belittle anyone..

github-actions[bot] avatar Jul 24 '22 22:07 github-actions[bot]