sammyne
sammyne

Reputation: 101

Why CGo-based build targeting GOOS=wasip1 failed

I cannot build a cgo-based project targeting GOOS=wasip1. Here is github repository helping reproduction.

Environment

Output of go env command goes as

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://goproxy.woa.com,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.woa.com+643d7a06+Ac5f5VOC4N8NUXdmhbm8pZSXIWfhek5JSmWdWrq7pLX4'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.4'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/github.com/sammyne/wasip1-cgo-broken-build/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1744286471=/tmp/go-build -gno-record-gcc-switches'

Project Layout

|-main.go         // depends on C-based bindings APIs
|-bindings
  |-bindings.c    // implementation of C-based bindings
  |-bindings.go   // adapters of C-based bindings APIs
  |-bindings.h    // headers of C-based bindings

Problem Reproduction

Building the project as

GOOS=wasip1 GOARCH=wasm go build -v -o hello-world.wasm .

produces errors as

package github.com/sammyne/wasip1-cgo-broken-build
        imports github.com/sammyne/wasip1-cgo-broken-build/bindings: build constraints exclude all Go files in /github.com/sammyne/wasip1-cgo-broken-build/bindings

Really appreciate if someone could help me out~

References

Upvotes: 1

Views: 101

Answers (0)

Related Questions