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 always get『# runtime/cgo ld: error: duplicate symbol: x_cgo_inittls』 #43399

Closed
VincentChen1212 opened this issue Dec 28, 2020 · 3 comments

Comments

@VincentChen1212
Copy link

VincentChen1212 commented Dec 28, 2020

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

$ go version
go version go1.15.6 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/vincent/Library/Caches/go-build"
GOENV="/Users/vincent/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Volumes/Service HD/CloudService/GoogleDrive/vincent/Workspaces/VC/VC.Language.Exercise/vcGolangExercise/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Volumes/Service HD/CloudService/GoogleDrive/vincent/Workspaces/VC/VC.Language.Exercise/vcGolangExercise"
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=""
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/ds/2v9832g575jblpl14n7p3nxh0000gn/T/go-build810088110=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

My OS is Mac 10.15.7.

gomobile bind -v -target=android helloWorld/hello

But get

runtime/cgo
# 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)
gomobile: go build -v -buildmode=c-shared -o=/var/folders/ds/2v9832g575jblpl14n7p3nxh0000gn/T/gomobile-work-050374355/android/src/main/jniLibs/armeabi-v7a/libgojni.so ./gobind failed: exit status 2

I try to solve with

  1. x/mobile/cmd/gomobile: gomobile build on simple program returns "ld: error: duplicate symbol: x_cgo_inittls" #42655
  2. gomobile: go build runtime/cgo: invalid flag in go:cgo_ldflag: -fembed-bitcode #42647 (comment)
  3. change ndk version (20.X / 21.X / 22.X)
    etc.

But always error.

Here is my .bash_profile

export ANDROID_HOME=/Applications/Android-Components/AndroidStudio/android-sdk/macosx
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/22.0.7026061
......

export GOROOT=/usr/local/go
export GOPATH=/Volumes/Service\ HD/CloudService/GoogleDrive/vincent/Workspaces/VC/VC.Language.Exercise/vcGolangExercise
export PATH=$GOROOT/bin:$GOPATH/bin:$PATH

PS:gomobile bind -v -target=ios helloWorld/hello:this is fine to generate .framework

PS:
截圖 2020-12-28 下午4 27 24

截圖 2020-12-28 下午4 43 43

What did you expect to see?

.aar

What did you see instead?

Thank you !!

@AlexRouSg
Copy link
Contributor

AlexRouSg commented Dec 28, 2020

Please describe how you have tried older NDK versions

If you changed the env var in .bash_profile you need to logout and back in for it to take effect

@egonelbre
Copy link
Contributor

Duplicate #42655

@ianlancetaylor
Copy link
Contributor

Closing as dup.

@golang golang locked and limited conversation to collaborators Dec 28, 2021
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

5 participants