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
x/mobile: problem with multiple definition using gobind #26298
Comments
Likely dup of #23555, which is fixed in the upcoming 1.11 release. Are you vendoring the same package with two different import paths? |
It's possible the same package is being vendored by multiple consumers, but (i don't think) on different paths. Also, the problem is not consistent. I saw the problem on windows; started clean and can build. Am now reproducing on linux. Our source is open, should be able to reproduce with Is there a build of 1.11 I can try? |
Retried with latest master (built from source on windows) set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\db\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=c:\dev\go
set GOPROXY=
set GORACE=
set GOROOT=C:\devtools\Go
set GOTMPDIR=
set GOTOOLDIR=C:\devtools\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\db\AppData\Local\Temp\go-build891562430=/tmp/go-build -gno-record-gcc-switches
set VGOMODROOT=```
Same result
```gomobile bind -target android -o bin/agent/ddagent.aar github.com/DataDog/datadog-agent/cmd/agent/android
gomobile: go build -buildmode=c-shared -o=C:\Users\db\AppData\Local\Temp\gomobile-work-083067355\android\src\main\jniLibs\armeabi-v7a\libgojni.so gobind failed: exit status 2
# gobind
C:\devtools\Go\pkg\tool\windows_amd64\link.exe: running c:\dev\go\pkg\gomobile\ndk-toolchains\arm\bin\arm-linux-androideabi-clang failed: exit status 1
c:\dev\go\pkg\gomobile\ndk-toolchains\arm\bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld: error: C:\Users\db\AppData\Local\Temp\go-link-853799315\000029.o: multiple definition of 'checkException'
c:\dev\go\pkg\gomobile\ndk-toolchains\arm\bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld: C:\Users\db\AppData\Local\Temp\go-link-853799315\000025.o: previous definition here
c:\dev\go\pkg\gomobile\ndk-toolchains\arm\bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld: error: C:\Users\db\AppData\Local\Temp\go-link-853799315\000029.o: multiple definition of 'lockJNI'
c:\dev\go\pkg\gomobile\ndk-toolchains\arm\bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld: C:\Users\db\AppData\Local\Temp\go-link-853799315\000025.o: previous definition here
c:\dev\go\pkg\gomobile\ndk-toolchains\arm\bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld: error: C:\Users\db\AppData\Local\Temp\go-link-853799315\000029.o: multiple definition of 'unlockJNI'
c:\dev\go\pkg\gomobile\ndk-toolchains\arm\bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld: C:\Users\db\AppData\Local\Temp\go-link-853799315\000025.o: previous definition here
clang60.exe: error: linker command failed with exit code 1 (use -v to see invocation)``` |
Thanks. That's not the same result. All of the It looks like those functions are defined in the global C namespace by golang.org/x/mobile/internal/mobileinit/ctx_android.go. @eliasnaur Any idea why those C functions are marked |
I don't believe so...
|
My understanding is that gobind itself uses golang.org/x/mobileinternal/mobileinit, so if you are also vendoring it that may be causing the multiple definition errors. Although, as I suggest above, the correct fix is likely to change ctx_android.go to mark the C functions as |
Just for giggles I grepped the entire source tree; the vendored x/mobile/internal/mobileinit/ctx_android.go is the only place This is the rev that
|
I'm not sure why |
I was able to make it compile by declaring those 3 fns as |
Change https://golang.org/cl/122897 mentions this issue: |
When is |
CL 122897 is merged. Go 1.11 is targeted for August. |
The changes to internal/mobileinit fixes golang/go#26298; the changes to the app package are only the easy pickings. Fixes golang/go#26298 Change-Id: I1ac49c57e417b852cb5ab1bdcb18c73db8c4475a Reviewed-on: https://go-review.googlesource.com/122897 Reviewed-by: Ian Lance Taylor <iant@golang.org>
The changes to internal/mobileinit fixes golang/go#26298; the changes to the app package are only the easy pickings. Fixes golang/go#26298 Change-Id: I1ac49c57e417b852cb5ab1bdcb18c73db8c4475a Reviewed-on: https://go-review.googlesource.com/122897 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.10.2 linux/amd64
(I have also experienced the problem with go1.10.2/windows)
Does this issue reproduce with the latest release?
reproduced with 1.10.3
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/"
GORACE=""
GOROOT="/root/.gimme/versions/go1.10.3.linux.amd64"
GOTMPDIR=""
GOTOOLDIR="/root/.gimme/versions/go1.10.3.linux.amd64/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
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"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build325883252=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Attempting to build a java
aar
(for a java app) using`gomobile bind -target android -o .aar github.com/
What did you expect to see?
Compiled aar
What did you see instead?
gomobile: go build -buildmode=c-shared -o=/tmp/gomobile-work-319151112/android/src/main/jniLibs/armeabi-v7a/libgojni.so gobind failed: exit status 2
gobind
/root/.gimme/versions/go1.10.3.linux.amd64/pkg/tool/linux_amd64/link: running /pkg/gomobile/ndk-toolchains/arm/bin/arm-linux-androideabi-clang failed: exit status 1
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /tmp/go-link-973277192/000028.o: multiple definition of '_cgo_dc57271482da_Cfunc__Cmalloc'
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: /tmp/go-link-973277192/000024.o: previous definition here
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /tmp/go-link-973277192/000029.o: multiple definition of '_cgo_dc57271482da_Cfunc_checkException'
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: /tmp/go-link-973277192/000025.o: previous definition here
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /tmp/go-link-973277192/000029.o: multiple definition of '_cgo_dc57271482da_Cfunc_free'
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: /tmp/go-link-973277192/000025.o: previous definition here
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /tmp/go-link-973277192/000029.o: multiple definition of '_cgo_dc57271482da_Cfunc_lockJNI'
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: /tmp/go-link-973277192/000025.o: previous definition here
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /tmp/go-link-973277192/000029.o: multiple definition of '_cgo_dc57271482da_Cfunc_unlockJNI'
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: /tmp/go-link-973277192/000025.o: previous definition here
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /tmp/go-link-973277192/000029.o: multiple definition of 'checkException'
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: /tmp/go-link-973277192/000025.o: previous definition here
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /tmp/go-link-973277192/000029.o: multiple definition of 'lockJNI'
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: /tmp/go-link-973277192/000025.o: previous definition here
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /tmp/go-link-973277192/000029.o: multiple definition of 'unlockJNI'
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: /tmp/go-link-973277192/000025.o: previous definition here
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /tmp/go-link-973277192/000031.o: multiple definition of '_cgo_dc57271482da_Cfunc___android_log_write'
/pkg/gomobile/ndk-toolchains/arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: /tmp/go-link-973277192/000027.o: previous definition here
clang60: error: linker command failed with exit code 1 (use -v to see invocation)
using downloaded android ndk r17b & android sdk tools
sdk-tools-linux-4333796
(didn't install android studio; attempting to create a command-line only docker build.The text was updated successfully, but these errors were encountered: