Go: x/mobile: gomobile bind fails with "invalid flag in #cgo CFLAGS: -fmodules" for target=ios

Created on 8 Feb 2018  ·  2Comments  ·  Source: golang/go

What version of Go are you using (go version)?

go version go1.9.4 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN="/Users/mbp/gopath/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mbp/gopath"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.9.4/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.9.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/nt/0hzfppd92jvbk99fhvnhy8ph0000gn/T/go-build761826753=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

Run gomobile build with:

gomobile bind -target=ios .

What did you expect to see?

Build to pass as with previous versions

What did you see instead?

gomobile: darwin-armv7: go build -pkgdir=/Users/mbp/gopath/pkg/gomobile/pkg_darwin_arm -tags ios -buildmode=c-archive -o /var/folders/nt/0hzfppd92jvbk99fhvnhy8ph0000gn/T/gomobile-work-290185797/libfp-arm.a /var/folders/nt/0hzfppd92jvbk99fhvnhy8ph0000gn/T/gomobile-work-290185797/src/iosbin/main.go failed: exit status 1
go build _/var/folders/nt/0hzfppd92jvbk99fhvnhy8ph0000gn/T/gomobile-work-290185797/src/gomobile_bind: invalid flag in #cgo CFLAGS: -fmodules

This does not happen for target=android builds.

FrozenDueToAge mobile

Most helpful comment

For anyone else that hits this, there's a workaround in the meantime:

export CGO_CFLAGS_ALLOW='-fmodules|-fblocks'

I didn't see anything in the 1.9 or 1.9.4 release notes, but the cgo docs were updated: https://golang.org/cmd/cgo/#hdr-Using_cgo_with_the_go_command.

All 2 comments

Closing in favor of the general whitelist collection issue in #23749.

For anyone else that hits this, there's a workaround in the meantime:

export CGO_CFLAGS_ALLOW='-fmodules|-fblocks'

I didn't see anything in the 1.9 or 1.9.4 release notes, but the cgo docs were updated: https://golang.org/cmd/cgo/#hdr-Using_cgo_with_the_go_command.

Was this page helpful?
0 / 5 - 0 ratings