Skip to content

llgo build -target=wasip1 silently emits a native executable #2263

Description

@cpunion

Reproducer

On current main (60c30f2ff) on Darwin/arm64:

package main

func main() {
	println("hello")
}
llgo build -target=wasip1 -o hello.wasm hello.go
file hello.wasm

Actual result:

hello.wasm: Mach-O 64-bit executable arm64

The build also prints native libuv/BDWGC dylib warnings, confirming that the named target did not reach the WASI toolchain. The command succeeds, so extension/magic validation is left to the user.

The direct environment path is different but is not a workaround on this revision:

GOOS=wasip1 GOARCH=wasm llgo build -tags=nogc -o hello.wasm hello.go

With LLVM 19 it reaches the WebAssembly backend and crashes while selecting internal/sync.(*HashTrieMap[any,any]).CompareAndDelete; in any case, it is distinct from the named-target bug above.

Expected

-target=wasip1 should either produce a WebAssembly v1 module (\0asm) using the resolved target profile or fail before linking. A post-link target/magic check would also prevent a successful native artifact from being returned for a WebAssembly target.

A small integration test can build the source above with -target=wasip1 and assert the four-byte WebAssembly magic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions