Skip to content

Wasm examples require wasi-libc to compile from dev builds #923

@justinclift

Description

@justinclift

Discovered a problem (and solution) earlier on today, when attempting to compile the TinyGo wasm examples in under the src/examples/wasm directory:

$ cd src/examples/wasm
$ make main
rm -rf ./html
mkdir ./html
cp ../../../targets/wasm_exec.js ./html/
tinygo build -o ./html/wasm.wasm -target wasm -no-debug ./main/main.go
tinygo:wasm-ld: error: cannot open /home/jc/go/src/github.com/tinygo-org/tinygo/lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a: No such file or directory
error: failed to link /tmp/tinygo685543697/main: failed to link using built-in wasm-ld
make: *** [Makefile:23: main] Error 1

The problem turned out to be that the wasi-libc submodule needs to be (manually) compiled first, before the compiling the wasm examples:

$ cd lib/wasi-libc
$ make WASM_CC=~/go/src/github.com/tinygo-org/tinygo/llvm-build/bin/clang \
  WASM_AR=~/go/src/github.com/tinygo-org/tinygo/llvm-build/bin/llvm-ar \
  WASM_NM=~/go/src/github.com/tinygo-org/tinygo/llvm-build/bin/llvm-nm

This compile step creates the libc.a file being complained about in the initial error.

The proper solution to this might be something like including this in the top level Makefile, so it's done automatically during the normal TinyGo compilation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions