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

cmd/cgo: cgo breaks multiple cgo packages linked with libgcc #7604

gopherbot opened this issue Mar 21, 2014 · 3 comments

cmd/cgo: cgo breaks multiple cgo packages linked with libgcc #7604

gopherbot opened this issue Mar 21, 2014 · 3 comments


Copy link

@gopherbot gopherbot commented Mar 21, 2014

by jim.deng:

What does 'go version' print?
go version devel +358e2b416518 Wed Mar 19 09:00:58 2014 -0700 darwin/amd64

What steps reproduce the problem?
If possible, include a link to a program on

1. Create a source tree that can be downloaded below:


2. Install android standalone ndk 49d following 4/ Invoking the compiler (the easy way):

3.  Run  the following command to build
export PATH=/path/to/android/toolchain-r9d/bin:$PATH

CGO_CFLAGS='-I /Users/jim_deng/workspace/android/toolchain-r9d/include -march=armv7-a
-mfloat-abi=softfp' \ 
CGO_LDFLAGS='-Wl,--fix-cortex-a8' \ 
CC=arm-linux-androideabi-gcc \ 
CXX=arm-linux-androideabi-g++ \ 
GOOS=linux \ 
GOARCH=arm \ 
go build -tags android -x

What happened?

Got multiple definition of '__aeabi_dcmpge' errors ...

What should have happened instead?

go build should succeed

Please provide any additional information below.

* Background discussion:!topic/golang-nuts/73NvFzLZpSY
* android tool chain cannot be linked with -lpthread.  I have to patch cgo not to add
-lpthread in the linker.
--- a/src/pkg/runtime/cgo/cgo.go        Wed Mar 19 09:00:58 2014 -0700
+++ b/src/pkg/runtime/cgo/cgo.go        Thu Mar 20 17:31:16 2014 -0700
@@ -14,7 +14,7 @@
-#cgo linux LDFLAGS: -lpthread
+#cgo linux,!android LDFLAGS: -lpthread
Copy link

@minux minux commented Mar 25, 2014

Comment 1:

I will take a look.

Labels changed: added release-go1.3, repo-main.

Status changed to Accepted.

Copy link

@rsc rsc commented Apr 3, 2014

Comment 2:

Labels changed: added release-go1.3maybe, removed release-go1.3.

Copy link

@rsc rsc commented May 9, 2014

Comment 3:

I don't know what's wrong here. Either gcc is generating objects with duplicate symbols
or the Go linker is misinterpreting the symbols as global when they are really static
(more likely). External linking might help but I thought that was already in place.
If you write your own wrapper for __aeabi_dcmpge and make both places refer to that
wrapper I think everything will be fine. For example:
#include <stdio.h>
void mydcmp(void) {
    __aeabi_dcmpge(0, 0);
static void Print() {
import "C"
#include <stdio.h>
void mydcmp(void);
static void Print() {
import "C"

Labels changed: added release-none, suggested, removed release-go1.3maybe.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc removed release-none labels Apr 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.