Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gomobile: go build runtime/cgo: invalid flag in go:cgo_ldflag: -fembed-bitcode #42647

Closed
neilalexander opened this issue Nov 16, 2020 · 4 comments

Comments

@neilalexander
Copy link
Contributor

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

$ go version
go version go1.15.5 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/neilalexander/Library/Caches/go-build"
GOENV="/Users/neilalexander/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/neilalexander/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/neilalexander/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/neilalexander/go/src/github.com/yggdrasil-network/yggdrasil-go/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/cv/wv7k9w2s4qdfjfd60nd7_5t40000gn/T/go-build915392521=/tmp/go-build -gno-record-gcc-switches -fno-common"

This problem started with macOS Big Sur. It worked on Catalina.

What did you do?

git clone https://github.com/yggdrasil-network/yggdrasil-go
cd yggdrasil-go
./build -i

... which is effectively doing the usual gomobile bind:

gomobile bind -target ios -tags mobile ...

What did you expect to see?

A completed build with an output .framework.

What did you see instead?

gomobile: darwin-arm64: go build -tags mobile ios -ldflags -X github.com/yggdrasil-network/yggdrasil-go/src/version.buildName=yggdrasil-develop -X github.com/yggdrasil-network/yggdrasil-go/src/version.buildVersion=0.3.15-0082 -s -w  -buildmode=c-archive -o /var/folders/cv/wv7k9w2s4qdfjfd60nd7_5t40000gn/T/gomobile-work-621527419/yggdrasil-arm64.a ./gobind failed: exit status 1
go: downloading golang.org/x/mobile v0.0.0-20200801112145-973feb4309de
go: downloading github.com/yggdrasil-network/yggdrasil-extras v0.0.0-20201115133139-13e9439a0b5a
go: downloading github.com/mitchellh/mapstructure v1.1.2
go: downloading github.com/Arceliar/phony v0.0.0-20191006174943-d0c68492aca0
go: downloading github.com/hjson/hjson-go v3.0.2-0.20200316202735-d5d0e8b0617d+incompatible
go: downloading github.com/gologme/log v0.0.0-20181207131047-4e5d8ccb38e8
go: found github.com/yggdrasil-network/yggdrasil-go/src/config in github.com/yggdrasil-network/yggdrasil-go v0.0.0-00010101000000-000000000000
go: found github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil in github.com/yggdrasil-network/yggdrasil-go v0.0.0-00010101000000-000000000000
go: found github.com/yggdrasil-network/yggdrasil-go/src/address in github.com/yggdrasil-network/yggdrasil-go v0.0.0-00010101000000-000000000000
go: found github.com/yggdrasil-network/yggdrasil-go/src/crypto in github.com/yggdrasil-network/yggdrasil-go v0.0.0-00010101000000-000000000000
go: found github.com/yggdrasil-network/yggdrasil-go/src/defaults in github.com/yggdrasil-network/yggdrasil-go v0.0.0-00010101000000-000000000000
go: found github.com/yggdrasil-network/yggdrasil-go/src/util in github.com/yggdrasil-network/yggdrasil-go v0.0.0-00010101000000-000000000000
go: found github.com/yggdrasil-network/yggdrasil-go/src/admin in github.com/yggdrasil-network/yggdrasil-go v0.0.0-00010101000000-000000000000
go: found github.com/yggdrasil-network/yggdrasil-go/src/multicast in github.com/yggdrasil-network/yggdrasil-go v0.0.0-00010101000000-000000000000
go: downloading golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d
go: downloading golang.org/x/net v0.0.0-20200301022130-244492dfa37a
go: downloading golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527
go build runtime/cgo: invalid flag in go:cgo_ldflag: -fembed-bitcode
@myroid
Copy link

myroid commented Nov 17, 2020

I have the same problem. And when I run build android, I get an error:

……
TERM='dumb' /Users/mac/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi16-clang -I . -fPIC -marm -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b039=/tmp/go-build -gno-record-gcc-switches -o $WORK/b039/_cgo_.o $WORK/b039/_cgo_main.o $WORK/b039/_x001.o $WORK/b039/_x002.o $WORK/b039/_x003.o $WORK/b039/_x004.o $WORK/b039/_x005.o $WORK/b039/_x006.o $WORK/b039/_x007.o $WORK/b039/_x008.o $WORK/b039/_x009.o $WORK/b039/_x010.o -g -O2 -llog -pie
# runtime/cgo
ld: error: duplicate symbol: x_cgo_inittls
>>> defined at gcc_android.c:90
>>>            $WORK/b039/_x003.o:(x_cgo_inittls)
>>> defined at gcc_linux_arm.c:13
>>>            $WORK/b039/_x006.o:(.bss+0x4)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
rm -r -f "$WORK"
……

@ianlancetaylor
Copy link
Contributor

@myroid The x_cgo_inittls problem looks like a completely different problem which should be discussed in a different issue. Thanks.

@ianlancetaylor
Copy link
Contributor

Looks like the golang.org/x/mobile build sets CGO_LDFLAGS, so this is a dup of #42565. It should be fixe din 1.15.6. Sorry for the trouble.

@ibigbug
Copy link

ibigbug commented Dec 2, 2020

Looks like the golang.org/x/mobile build sets CGO_LDFLAGS, so this is a dup of #42565. It should be fixe din 1.15.6. Sorry for the trouble.

Sorry to comment on closed ticket: when will the new version get released and any workarounds for the current version?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants
@neilalexander @ibigbug @ianlancetaylor @myroid @gopherbot and others