Skip to content

wasm-unknown: cannot build binaries without main #4670

@orsinium

Description

@orsinium

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wasmWebAssembly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions