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

wasm-unknown: cannot build binaries without main #4670

Closed
orsinium opened this issue Dec 20, 2024 · 2 comments
Closed

wasm-unknown: cannot build binaries without main #4670

orsinium opened this issue Dec 20, 2024 · 2 comments
Labels
wasm WebAssembly

Comments

@orsinium
Copy link

I have a project using the following target.json:

{
  "llvm-target": "wasm32-unknown-unknown",
  "cpu": "generic",
  "features": "+mutable-globals,+nontrapping-fptoint,+sign-ext,+bulk-memory",
  "build-tags": ["tinygo.wasm", "wasm_unknown"],
  "goos": "linux",
  "goarch": "arm",
  "linker": "wasm-ld",
  "rtlib": "compiler-rt",
  "scheduler": "none",
  "gc": "leaking",
  "cflags": ["-mno-bulk-memory", "-mnontrapping-fptoint", "-msign-ext"],
  "ldflags": [
    "--allow-undefined",
    "--no-demangle",
    "--stack-first",
    "--no-entry",
    "-zstack-size=14752"
  ],
  "extra-files": ["src/runtime/asm_tinygowasm.S"]
}

In tinygo 0.33.0, the presence of "--no-entry" linker flag allows the project to be build without defining main function. However, doing so in 0.34.0 adds env.main/main(i32) import in the wasm binary. Bisecting showed that the issue is introduced in #4451.

@deadprogram deadprogram added the wasm WebAssembly label Dec 21, 2024
@orsinium
Copy link
Author

Fixed by adding -buildmode c-shared in 0.35.0 ✅ Found solution here: dylibso/xtp-go-bindgen#30

@deadprogram
Copy link
Member

It would be good to add this info someplace in the TinyGo docs for WASM, probably.

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

No branches or pull requests

2 participants