x/mobile/cmd/gomobile: gomobile build on simple program returns "ld: error: duplicate symbol: x_cgo_inittls" #42655
Comments
Exporting ANDROID_NDK_HOME may also fail.
|
Yes, exactly, that is why I renamed ndk-bundle so it couldn't find it as I wrote in the issue. I would have preferred if ANDROID_NDK_HOME tok precedence over the presence of ndk-bundle, but that is another issue I guess :-) |
Any idea what the root problem is? I can confirm that compiling a simple go program (anything that uses net) fails for me on NDK version 22, but works for NDK 21. I'm not using gomobile, but invoking the compiler directly like this: GOOS=android GOARCH=arm64 CGO_ENABLED=1 CC=$NDK_ROOT/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang go build See my issue (resolved for now by downgrading NDK version) here: #42725 |
I think "extern" keyword is needed before |
Solved by downloading older version of NDK 21.3.6528147 |
Adding extern to the
Adding extern to the android file doesn't work:
|
Change https://golang.org/cl/280312 mentions this issue: |
@gopherbot Please open backport issues Although this was filed against x/mobile, the fix is to runtime/cgo in the standard library. This is caused by a change in the default behavior of the C compiler. Anybody using an older release of Go with a new C compiler will run into this problem. Since the fix is small and safe, we should backport it. |
Backport issue(s) opened: #43405 (for 1.14), #43406 (for 1.15). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Fixes golang#42655 Change-Id: I7d2b70098a4ba4dcb325fb0be076043789b86135 Reviewed-on: https://go-review.googlesource.com/c/go/+/280312 Run-TryBot: Elias Naur <mail@eliasnaur.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Elias Naur <mail@eliasnaur.com>
NDK 22.0.7026061 same problem, 21.3.6528147 works. gomobile version +e6ae53a Thu Dec 17 15:07:44 2020 +0000 (android); androidSDK=/home/m/app/android-sdk/platforms/android-30 |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, latest release is 1.15.5
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
run
gomobile build
on a simple script like:
What did you expect to see?
That the process succeeded
What did you see instead?
I think this comes from latest NDK upgrade
I have had a quite hard time to prove that the ndk is at least part of the issue since ndk-bundle precedence is hard coded in env.go
https://github.com/golang/mobile/blob/973feb4309de5c3aad0553fc987d76abf1fa58f7/cmd/gomobile/env.go#L181
So I renamed ndk-bundle folder temporary so I could change ndk with ANDROID_NDK_HOME
Then:
fails with the error in this issue
but this works without issue:
and
By using the -x flag I could confirm that the older NDK then was used instead of ndk-bundle.
This issue was also mentioned in #42647 (comment)
The text was updated successfully, but these errors were encountered: