Skip to content

cmd/link: Cross-compiled binaries using cgo selects incorrect ld-linux #12443

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

Closed
17twenty opened this issue Sep 2, 2015 · 14 comments
Closed
Milestone

Comments

@17twenty
Copy link

17twenty commented Sep 2, 2015

I am trying to use a Yocto toolchain to build cross-platform binaries for a Gumstix targte using the cgo bindings with the following code:

package binding

// #include <stdlib.h>
// #include <stdio.h>
/*  void myprint(char* s) {
        printf("%s", s);
    }
*/
import "C"

func Random() int {
    return int(C.random())
}

func PrintHello() {
    C.myprint(C.CString("Hello\n"))
}

func Seed(i int) {
    C.srandom(C.uint(i))
}
...
package main
import (
    "./binding"
    "fmt"
)

func main() {
    binding.PrintHello()
    binding.Seed(1)
    fmt.Println(binding.Random())
    binding.Seed(2)
    fmt.Println(binding.Random())
    binding.Seed(3)
    fmt.Println(binding.Random())
}

I built it using the following:

nick@bignick:~/demo/cgodemo$ CC=arm-poky-linux-gnueabi-gcc CGO_CFLAGS="-march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi" CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=5 go build -o Foo_ARM *.go

When trying to run the executable on target you groan and see:

root@target:~# ./Foo_ARM
-sh: ./Foo_ARM: No such file or directory

The issue seems to be that the runtime loader used is incorrect
If you run readelf you can see it's embedding ld-linux.so.3 as the linux loader but the toolchain is configured for ld-linux-armhf.so.3

nick@bignick:~/demo/cgodemo$ arm-poky-linux-gnueabi-readelf Foo_ARM -a | grep ld-
  [ 3] .note.gnu.build-i NOTE            00008188 000188 000024 00   A  0   0  4
      [Requesting program interpreter: /lib/ld-linux.so.3]

I'm not sure why this has happened as those CC and CFLAGS are exactly that used to produce other binaries which don't have this issue i.e.:

nick@bignick:~/demo/cgodemo$ arm-poky-linux-gnueabi-readelf  NormalCrossCompiledHelloWorld -a | grep ld-
  [ 3] .note.gnu.build-i NOTE            00008170 000170 000024 00   A  0   0  4
      [Requesting program interpreter: /lib/ld-linux-armhf.so.3]
   03     .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .ARM.exidx .eh_frame 
   06     .note.ABI-tag .note.gnu.build-id 
 0x00000001 (NEEDED)                     Shared library: [ld-linux-armhf.so.3]
  000000: Version: 1  File: ld-linux-armhf.so.3  Cnt: 1

After a bit of faffing and checking out the binaries a suggested workaround is simply to create a softlink between the two but this should ideally be fixed when building:

ln -s /lib/ld-linux-armhf.so.3 /lib/ld-linux.so.3
root@target:/lib# ~/Foo_ARM 
Hello
1804289383
1505335290
1205554746

Any suggestions?

@davecheney
Copy link
Contributor

This is usually gnu multi arch which decided to move the location of the loader .so.

I don't know where you got that tool chain from, but you may need a different one.

In any case, you found the workaround which is to create a symlink to the expected location of the linker. If you grep for that location in the go source, I think there is a comment explaining it.

On 2 Sep 2015, at 10:48, Nick Glynn notifications@github.com wrote:

I am trying to use a Yocto toolchain to build cross-platform binaries for a Gumstix targte using the cgo bindings with the following code:

package binding

// #include <stdlib.h>
// #include <stdio.h>
/* void myprint(char* s) {
printf("%s", s);
}
*/
import "C"

func Random() int {
return int(C.random())
}

func PrintHello() {
C.myprint(C.CString("Hello\n"))
}

func Seed(i int) {
C.srandom(C.uint(i))
}
...
package main
import (
"./binding"
"fmt"
)

func main() {
binding.PrintHello()
binding.Seed(1)
fmt.Println(binding.Random())
binding.Seed(2)
fmt.Println(binding.Random())
binding.Seed(3)
fmt.Println(binding.Random())
}

I built it using the following:

nick@bignick:~/demo/cgodemo$ CC=arm-poky-linux-gnueabi-gcc CGO_CFLAGS="-march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi" CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=5 go build -o Foo_ARM *.go
When trying to run the executable on target you groan and see:

root@target:~# ./Foo_ARM
-sh: ./Foo_ARM: No such file or directory
The issue seems to be that the runtime loader used is incorrect
If you run readelf you can see it's embedding ld-linux.so.3 as the linux loader but the toolchain is configured for ld-linux-armhf.so.3

nick@bignick:~/demo/cgodemo$ arm-poky-linux-gnueabi-readelf Foo_ARM -a | grep ld-
[ 3] .note.gnu.build-i NOTE 00008188 000188 000024 00 A 0 0 4
[Requesting program interpreter: /lib/ld-linux.so.3]
I'm not sure why this has happened as those CC and CFLAGS are exactly that used to produce other binaries which don't have this issue i.e.:

nick@bignick:~/demo/cgodemo$ arm-poky-linux-gnueabi-readelf NormalCrossCompiledHelloWorld -a | grep ld-
[ 3] .note.gnu.build-i NOTE 00008170 000170 000024 00 A 0 0 4
[Requesting program interpreter: /lib/ld-linux-armhf.so.3]
03 .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .ARM.exidx .eh_frame
06 .note.ABI-tag .note.gnu.build-id
0x00000001 (NEEDED) Shared library: [ld-linux-armhf.so.3]
000000: Version: 1 File: ld-linux-armhf.so.3 Cnt: 1
After a bit of faffing and checking out the binaries a suggested workaround is simply to create a softlink between the two but this should ideally be fixed when building:

ln -s /lib/ld-linux-armhf.so.3 /lib/ld-linux.so.3
root@target:/lib# ~/Foo_ARM
Hello
1804289383
1505335290
1205554746
Any suggestions?


Reply to this email directly or view it on GitHub.

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Sep 2, 2015
@ianlancetaylor ianlancetaylor changed the title Cross-compiled binaries using cgo selects incorrect ld-linux cmd/link: Cross-compiled binaries using cgo selects incorrect ld-linux Sep 2, 2015
@ianlancetaylor
Copy link
Member

If you are using cgo, then the Go linker should be invoking the system linker, and that is where the interpreter is being set. Try your build with -ldflags=-v. That should show how the system linker is being run.

@17twenty
Copy link
Author

17twenty commented Sep 2, 2015

The toolchain is created by the Yocto Project (as part of a their Creating a toolchain section )

I would argue that that's not quite expected behavior on Go's part rather than the toolchain which has been fairly battletested by the Yocto crowd but I'm happy to be wrong 😄

From standard compilation you can see that ld-linux-armhf.so.3 is present...

$CC -Xlinker -v hello.c -o hello | grep ld-linux
collect2 version 4.9.1
/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/ld -plugin /opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/liblto_plugin.so -plugin-opt=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccvKwWLt.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi --build-id --eh-frame-hdr --hash-style=gnu -dynamic-linker /lib/ld-linux-armhf.so.3 -X -m armelf_linux_eabi -o hello /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/crt1.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/crti.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/crtbegin.o -L/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1 -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/lib -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1 -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib -v /tmp/ccYPfi3v.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/crtend.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/crtn.o

But the same snippet from the go compilation has:

# runtime/cgo
Using built-in specs.
COLLECT_GCC=arm-poky-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/lto-wrapper
Target: arm-poky-linux-gnueabi
Configured with: /home/nick/yocto-build/build/tmp/work-shared/gcc-4.9.1-r0/gcc-4.9.1/configure --build=i686-linux --host=i686-pokysdk-linux --target=arm-poky-linux-gnueabi --pref
ix=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr --exec_prefix=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr --bindir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/bin/arm-
poky-linux-gnueabi --sbindir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --libexecdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-p
oky-linux-gnueabi --datadir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share --sysconfdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/etc --sharedstatedir=/opt/poky/1.7.1/sy
sroots/i686-pokysdk-linux/com --localstatedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/var --libdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi 
--includedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/include --oldincludedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/include --infodir=/opt/poky/1.7.1/sysroots/i6
86-pokysdk-linux/usr/share/info --mandir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/ho
me/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-multilib --enable-c99 -
-enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=arm-poky-linux-gnueabi- --without-local-prefix --enable-target-optspace --enable-lto --enable-libss
p --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=gnu --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enab
le-cheaders=c_global --with-gxx-include-dir=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/include/c++/4.9.1 --with-build-time-tools=/home/nick/yocto-build/b
uild/tmp/sysroots/i686-linux/usr/arm-poky-linux-gnueabi/bin --with-sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi --with-build-sysroot=/home/nick/yocto-b
uild/build/tmp/sysroots/overo --enable-poison-system-directories --with-mpfr=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --with-mpc=/home/nick/yocto-bu
ild/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --enable-nls --with-arch=armv7-a
Thread model: posix
gcc version 4.9.1 (GCC) 
COMPILER_PATH=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib
exec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/:/opt/poky
/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc
/arm-poky-linux-gnueabi/
LIBRARY_PATH=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-
gnueabi/lib/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi
/usr/lib/
COLLECT_GCC_OPTIONS='-I' '/home/nick/go-arm/src/runtime/cgo' '-fPIC' '-marm' '-pthread' '-fmessage-length=0' '-o' '/tmp/go-build025154392/runtime/cgo/_obj/_cgo_.o' '-v' '-pie' '-
march=armv7-a' '-mtls-dialect=gnu'
 /opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/collect2 -plugin /opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/
libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/liblto_plugin.so -plugin-opt=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/ar
m-poky-linux-gnueabi/4.9.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccFi7MLt.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lpt
hread -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi --
build-id --eh-frame-hdr --hash-style=gnu -dynamic-linker /lib/ld-linux.so.3 -X -m armelf_linux_eabi -pie -o $WORK/runtime/cgo/_obj/_cgo_.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp
-neon-poky-linux-gnueabi/usr/lib/Scrt1.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/crti.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gn
ueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/crtbeginS.o -L/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1 -L/opt/poky/1
.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/lib -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1 -L/opt/poky/1.7.1/
sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib $WORK/runtime/cgo/_obj/_cgo_main.o $WORK/runtime/cgo/_obj/_cgo_export.o $WORK/runtime/cgo/_obj/cgo.cgo2.o $WORK/runtime/cg
o/_obj/gcc_fatalf.o $WORK/runtime/cgo/_obj/gcc_libinit.o $WORK/runtime/cgo/_obj/gcc_linux_arm.o $WORK/runtime/cgo/_obj/gcc_setenv.o $WORK/runtime/cgo/_obj/gcc_util.o $WORK/runtim
e/cgo/_obj/gcc_arm.o -lpthread -lgcc --as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s --no-as-needed /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-l
inux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/crtendS.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/crtn.o
# runtime/cgo

...SNIP...

How can it be controlled to pick a specific/default one?

@ianlancetaylor
Copy link
Member

What is the output of arm-poky-linux-gnueabi-gcc -dumpspecs?

@minux
Copy link
Member

minux commented Sep 2, 2015 via email

@17twenty
Copy link
Author

17twenty commented Sep 2, 2015

*asm:
%{mbig-endian:-EB} %{mlittle-endian:-EL} %(asm_cpu_spec) %{mapcs-*:-mapcs-%*} %(subtarget_asm_float_spec) %{mthumb-interwork:-mthumb-interwork} %{mfloat-abi=*} %{mfpu=*} %(subtarget_extra_asm_spec)

*asm_debug:
%{!g0:%{gstabs*:--gstabs}%{!gstabs*:%{g*:--gdwarf2}}} %{fdebug-prefix-map=*:--debug-prefix-map %*}

*asm_final:
%{gsplit-dwarf: 
       objcopy --extract-dwo     %{c:%{o*:%*}%{!o*:%b%O}}%{!c:%U%O}      %{c:%{o*:%:replace-extension(%{o*:%*} .dwo)}%{!o*:%b.dwo}}%{!c:%b.dwo} 
       objcopy --strip-dwo   %{c:%{o*:%*}%{!o*:%b%O}}%{!c:%U%O}     }

*asm_options:
%{-target-help:%:print-asm-header()} %{v} %{w:-W} %{I*} %a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}

*invoke_as:
%{!fwpa*:   %{fcompare-debug=*|fdump-final-insns=*:%:compare-debug-dump-opt()}   %{!S:-o %|.s |
 as %(asm_options) %m.s %A }  }

*cpp:
%(subtarget_cpp_spec)                   %{mfloat-abi=soft:%{mfloat-abi=hard:                        %e-mfloat-abi=soft and -mfloat-abi=hard may not be used together}} %{mbig-endian:%{mlittle-endian:                          %e-mbig-endian and -mlittle-endian may not be used together}}

*cpp_options:
%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w} %{f*} %{g*:%{!g0:%{g*} %{!fno-working-directory:-fworking-directory}}} %{O*} %{undef} %{save-temps*:-fpch-preprocess}

*cpp_debug_options:
%{d*}

*cpp_unique_options:
%{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*&F*} %{P} %I %{MD:-MD %{!o:%b.d}%{o*:%.d%*}} %{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}} %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*} %{!E:%{!M:%{!MM:%{!MT:%{!MQ:%{MD|MMD:%{o*:-MQ %*}}}}}}} %{remap} %{g3|ggdb3|gstabs3|gcoff3|gxcoff3|gvms3:-dD} %{!iplugindir*:%{fplugin*:%:find-plugindir()}} %{H} %C %{D*&U*&A*} %{i*} %Z %i %{E|M|MM:%W{o*}}

*trad_capable_cpp:
cc1 -E %{traditional|traditional-cpp:-traditional-cpp}

*cc1:
%{!mandroid|tno-android-cc:%{profile:-p} %{%:sanitize(address):-funwind-tables};:%{profile:-p} %{%:sanitize(address):-funwind-tables} %{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} %{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}}

*cc1_options:
%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}} %{!iplugindir*:%{fplugin*:%:find-plugindir()}} %1 %{!Q:-quiet} %{!dumpbase:-dumpbase %B} %{d*} %{m*} %{aux-info*} %{fcompare-debug-second:%:compare-debug-auxbase-opt(%b)}  %{!fcompare-debug-second:%{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}}%{!c:%{!S:-auxbase %b}}  %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs} %{v:-version} %{pg:-p} %{p} %{f*} %{undef} %{Qn:-fno-ident} %{Qy:} %{-help:--help} %{-target-help:--target-help} %{-version:--version} %{-help=*:--help=%*} %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}} %{fsyntax-only:-o %j} %{-param*} %{coverage:-fprofile-arcs -ftest-coverage}

*cc1plus:
%{!mandroid|tno-android-cc:;:%{!fexceptions:%{!fno-exceptions: -fno-exceptions}} %{!frtti:%{!fno-rtti: -fno-rtti}}}

*link_gcc_c_sequence:
%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}

*link_ssp:
%{fstack-protector:}

*endfile:
%{!mandroid|tno-android-ld:%{fvtable-verify=none:%s;      fvtable-verify=preinit:vtv_end_preinit.o%s;      fvtable-verify=std:vtv_end.o%s}    %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s;:%{shared: crtend_so%O%s;: crtend_android%O%s}}

*link:
%{!r:--build-id} %{!static:--eh-frame-hdr} --hash-style=gnu %{mcpu=arm8|mcpu=arm810|mcpu=strongarm*|march=armv4: --fix-v4bx}%{mcpu=arm8|mcpu=arm810|mcpu=strongarm*|march=armv4: --fix-v4bx} %{mbig-endian:%{march=armv7-a|mcpu=cortex-a5           |mcpu=cortex-a7                                         |mcpu=cortex-a8|mcpu=cortex-a9|mcpu=cortex-a15          |mcpu=cortex-a12                       |mcpu=cortex-a15.cortex-a7                  |mcpu=cortex-a53                    |mcpu=cortex-a57                    |mcpu=cortex-a57.cortex-a53                 |mcpu=marvell-pj4                       |mcpu=generic-armv7-a                                   |march=armv7ve                                      |march=armv7-m|mcpu=cortex-m3                           |march=armv7e-m|mcpu=cortex-m4                          |march=armv6-m|mcpu=cortex-m0                           |march=armv8-a                      :%{!r:--be8}}}%{!mandroid|tno-android-ld:%{h*}    %{static:-Bstatic}    %{shared:-shared}    %{symbolic:-Bsymbolic}    %{!static:      %{rdynamic:-export-dynamic}      -dynamic-linker %{muclibc:/lib/ld-uClibc.so.0;:%{mbionic:/system/bin/linker;:%{mfloat-abi=hard:/lib/ld-linux-armhf.so.3}     %{mfloat-abi=soft*:/lib/ld-linux.so.3}     %{!mfloat-abi=*:/lib/ld-linux.so.3}}}}    -X    %{mbig-endian:-EB} %{mlittle-endian:-EL} -m armelf_linux_eabi;:%{h*}    %{static:-Bstatic}    %{shared:-shared}    %{symbolic:-Bsymbolic}    %{!static:      %{rdynamic:-export-dynamic}      -dynamic-linker %{muclibc:/lib/ld-uClibc.so.0;:%{mbionic:/system/bin/linker;:%{mfloat-abi=hard:/lib/ld-linux-armhf.so.3}     %{mfloat-abi=soft*:/lib/ld-linux.so.3}     %{!mfloat-abi=*:/lib/ld-linux.so.3}}}}    -X    %{mbig-endian:-EB} %{mlittle-endian:-EL} -m armelf_linux_eabi %{shared: -Bsymbolic}}

*lib:
%{!mandroid|tno-android-ld:%{pthread:-lpthread} %{shared:-lc}    %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}};:%{shared:-lc}    %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}} %{!static: -ldl}}

*link_gomp:


*libgcc:
%{static|static-libgcc:-lgcc -lgcc_eh}%{!static:%{!static-libgcc:%{!shared-libgcc:-lgcc --as-needed -lgcc_s --no-as-needed}%{shared-libgcc:-lgcc_s%{!shared: -lgcc}}}}

*startfile:
%{!mandroid|tno-android-ld:%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}    crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}    %{fvtable-verify=none:%s;      fvtable-verify=preinit:vtv_start_preinit.o%s;      fvtable-verify=std:vtv_start.o%s};:%{shared: crtbegin_so%O%s;:  %{static: crtbegin_static%O%s;: crtbegin_dynamic%O%s}}}

*cross_compile:
1

*version:
4.9.1

*multilib:
. ;

*multilib_defaults:


*multilib_extra:


*multilib_matches:


*multilib_exclusions:


*multilib_options:


*multilib_reuse:


*linker:
collect2

*linker_plugin_file:


*lto_wrapper:


*lto_gcc:


*link_libgcc:
%D

*md_exec_prefix:


*md_startfile_prefix:


*md_startfile_prefix_1:


*startfile_prefix_spec:


*sysroot_spec:
--sysroot=%R

*sysroot_suffix_spec:


*sysroot_hdrs_suffix_spec:


*self_spec:


*subtarget_cpp_spec:
%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}

*asm_cpu_spec:
 %{mcpu=generic-*:-march=%*;   :%{march=*:-march=%*}} %{mcpu=*:-mcpu=%:rewrite_mcpu(%{mcpu=*:%*})}

*subtarget_extra_asm_spec:
%{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu;:-meabi=5}%{mcpu=arm8|mcpu=arm810|mcpu=strongarm*|march=armv4: --fix-v4bx}

*subtarget_asm_float_spec:
%{mapcs-float:-mfloat}

*link_command:
%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:    %(linker) %{!fno-use-linker-plugin:%{!fno-lto:     -plugin %(linker_plugin_file)     -plugin-opt=%(lto_wrapper)     -plugin-opt=-fresolution=%u.res     %{!nostdlib:%{!nodefaultlibs:%:pass-through-libs(%(link_gcc_c_sequence))}}     }}%{flto|flto=*:%<fcompare-debug*}     %{flto} %{flto=*} %l %{pie:-pie} %{fuse-ld=*:-fuse-ld=%*}    %X %{o*} %{e*} %{N} %{n} %{r}    %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} %{!nostdlib:%{fvtable-verify=std: -lvtv -u_vtable_map_vars_start -u_vtable_map_vars_end}    %{fvtable-verify=preinit: -lvtv -u_vtable_map_vars_start -u_vtable_map_vars_end}}     %{Wno-poison-system-directories:--no-poison-system-directories}    %{Werror=poison-system-directories:--error-poison-system-directories}    %{static:} %{L*} %(mfwrap) %(link_libgcc) %{!nostdlib:%{!nodefaultlibs:%{%:sanitize(address):%{!shared:libasan_preinit%O%s} %{static-libasan:%{!shared:-Bstatic --whole-archive -lasan --no-whole-archive -Bdynamic}}%{!static-libasan:-lasan}}     %{%:sanitize(thread):%{static-libtsan:%{!shared:-Bstatic --whole-archive -ltsan --no-whole-archive -Bdynamic}}%{!static-libtsan:-ltsan}}}} %o    %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}    %{fcilkplus:%:include(libcilkrts.spec)%(link_cilkrts)}    %{fgnu-tm:%:include(libitm.spec)%(link_itm)}    %(mflib)  %{fsplit-stack: --wrap=pthread_create}    %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} %{!nostdlib:%{!nodefaultlibs:%{%:sanitize(address): %{static-libasan:%:include(libsanitizer.spec)%(link_libasan)}    %{static:%ecannot specify -static with -fsanitize=address}    %{%:sanitize(thread):%e-fsanitize=address is incompatible with -fsanitize=thread}}    %{%:sanitize(thread): %{static-libtsan:%:include(libsanitizer.spec)%(link_libtsan)}    %{!pie:%{!shared:%e-fsanitize=thread linking must be done with -pie or -shared}}}    %{%:sanitize(undefined):%{static-libubsan:-Bstatic} -lubsan %{static-libubsan:-Bdynamic} %{static-libubsan:%:include(libsanitizer.spec)%(link_libubsan)}}    %{%:sanitize(leak):%{!shared:%{static-liblsan:-Bstatic} -llsan %{static-liblsan:-Bdynamic} %{static-liblsan:%:include(libsanitizer.spec)%(link_liblsan)}}}}}     %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}    %{!nostdlib++:}    %{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}

@17twenty
Copy link
Author

17twenty commented Sep 2, 2015

@minux

nick@bignick:~/demo/cgodemo/GoWithC$ CC=arm-poky-linux-gnueabi-gcc  CGO_CFLAGS="-march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi"  CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags="-linkmode=external" -o Foo_ARM *.go
nick@bignick:~/demo/cgodemo/GoWithC$ arm-poky-linux-gnueabi-readelf Foo_ARM -a | grep ld-  [ 4] .note.gnu.build-i NOTE            00008200 000200 000024 00   A  0   0  4
      [Requesting program interpreter: /lib/ld-linux.so.3]
   03     .interp .note.ABI-tag .note.go.buildid .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .typelink .gopclntab .ARM.exidx .eh_frame 
   08     .note.gnu.build-id 

Not a blind bit of difference sadly, as mentioned - there's some hardcoding for EABI vs OABI in cmd/link/internal/arm/obj.go which seems to be the issue.

@minux
Copy link
Member

minux commented Sep 2, 2015 via email

@17twenty
Copy link
Author

17twenty commented Sep 2, 2015

CC=arm-poky-linux-gnueabi-gcc  CGO_CFLAGS="-march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi"  CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags="-linkmode=external -v" -o Foo_ARM *.go
# command-line-arguments
HEADER = -H5 -T0x11000 -D0x0 -R0x1000
searching for runtime.a in $WORK/runtime.a
searching for math.a in $WORK/math.a
 0.01 deadcode
 0.04 pclntab=259106 bytes, funcdata total 70688 bytes
 0.05 dodata
 0.06 reloc
 0.06 asmb
 0.07 datblk
 0.08 sym
 0.08 elfsym
 0.08 symsize = 44192
 0.08 symsize = 44448
 0.08 dwarf
 0.08 symsize = 44448
 0.11 dwarf pass 2.
 0.13 header
host link: "arm-poky-linux-gnueabi-gcc" "-marm" "-gdwarf-2" "-o" "/tmp/go-build047361532/command-line-arguments/_obj/exe/a.out" "-rdynamic" "/tmp/go-link-012454709/000000.o" "/tmp/go-link-012454709/000001.o" "/tmp/go-link-012454709/go.o" "-g" "-O2" "-g" "-O2" "-lpthread"
 0.17 cpu time
43095 symbols
31912 liveness data

Combining with the -v you get:

# runtime/cgo
Using built-in specs.
COLLECT_GCC=arm-poky-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/lto-wrapper
Target: arm-poky-linux-gnueabi
Configured with: /home/nick/yocto-build/build/tmp/work-shared/gcc-4.9.1-r0/gcc-4.9.1/configure --build=i686-linux --host=i686-pokysdk-linux --target=arm-poky-linux-gnueabi --prefix=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr --exec_prefix=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr --bindir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --sbindir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --libexecdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi --datadir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share --sysconfdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/etc --sharedstatedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/com --localstatedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/var --libdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi --includedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/include --oldincludedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/include --infodir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share/info --mandir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=arm-poky-linux-gnueabi- --without-local-prefix --enable-target-optspace --enable-lto --enable-libssp --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=gnu --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global --with-gxx-include-dir=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/include/c++/4.9.1 --with-build-time-tools=/home/nick/yocto-build/build/tmp/sysroots/i686-linux/usr/arm-poky-linux-gnueabi/bin --with-sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi --with-build-sysroot=/home/nick/yocto-build/build/tmp/sysroots/overo --enable-poison-system-directories --with-mpfr=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --with-mpc=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --enable-nls --with-arch=armv7-a
Thread model: posix
gcc version 4.9.1 (GCC) 
COMPILER_PATH=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/
LIBRARY_PATH=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/lib/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/
COLLECT_GCC_OPTIONS='-I' '/usr/local/go/src/runtime/cgo' '-fPIC' '-marm' '-pthread' '-fmessage-length=0' '-o' '/tmp/go-build065055181/runtime/cgo/_obj/_cgo_.o' '-v' '-pie' '-march=armv7-a' '-mtls-dialect=gnu'
 /opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/collect2 -plugin /opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/liblto_plugin.so -plugin-opt=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccJais2y.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi --build-id --eh-frame-hdr --hash-style=gnu -dynamic-linker /lib/ld-linux.so.3 -X -m armelf_linux_eabi -pie -o $WORK/runtime/cgo/_obj/_cgo_.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/Scrt1.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/crti.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/crtbeginS.o -L/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1 -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/lib -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1 -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib $WORK/runtime/cgo/_obj/_cgo_main.o $WORK/runtime/cgo/_obj/_cgo_export.o $WORK/runtime/cgo/_obj/cgo.cgo2.o $WORK/runtime/cgo/_obj/gcc_fatalf.o $WORK/runtime/cgo/_obj/gcc_libinit.o $WORK/runtime/cgo/_obj/gcc_linux_arm.o $WORK/runtime/cgo/_obj/gcc_setenv.o $WORK/runtime/cgo/_obj/gcc_util.o $WORK/runtime/cgo/_obj/gcc_arm.o -lpthread -lgcc --as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s --no-as-needed /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/crtendS.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/crtn.o
# runtime/cgo
Using built-in specs.
COLLECT_GCC=arm-poky-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/lto-wrapper
Target: arm-poky-linux-gnueabi
Configured with: /home/nick/yocto-build/build/tmp/work-shared/gcc-4.9.1-r0/gcc-4.9.1/configure --build=i686-linux --host=i686-pokysdk-linux --target=arm-poky-linux-gnueabi --prefix=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr --exec_prefix=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr --bindir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --sbindir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --libexecdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi --datadir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share --sysconfdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/etc --sharedstatedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/com --localstatedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/var --libdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi --includedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/include --oldincludedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/include --infodir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share/info --mandir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=arm-poky-linux-gnueabi- --without-local-prefix --enable-target-optspace --enable-lto --enable-libssp --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=gnu --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global --with-gxx-include-dir=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/include/c++/4.9.1 --with-build-time-tools=/home/nick/yocto-build/build/tmp/sysroots/i686-linux/usr/arm-poky-linux-gnueabi/bin --with-sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi --with-build-sysroot=/home/nick/yocto-build/build/tmp/sysroots/overo --enable-poison-system-directories --with-mpfr=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --with-mpc=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --enable-nls --with-arch=armv7-a
Thread model: posix
gcc version 4.9.1 (GCC) 
COMPILER_PATH=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/
LIBRARY_PATH=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/lib/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/
COLLECT_GCC_OPTIONS='-I' '/usr/local/go/src/runtime/cgo' '-fPIC' '-marm' '-pthread' '-fmessage-length=0' '-o' '/tmp/go-build065055181/runtime/cgo/_obj/_all.o' '-v' '-nostdlib' '-march=armv7-a' '-mtls-dialect=gnu'
 /opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/collect2 -plugin /opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/liblto_plugin.so -plugin-opt=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccVUbnHB.res --sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi --build-id --eh-frame-hdr --hash-style=gnu -dynamic-linker /lib/ld-linux.so.3 -X -m armelf_linux_eabi -o $WORK/runtime/cgo/_obj/_all.o -L/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1 -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/lib -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1 -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib $WORK/runtime/cgo/_obj/_cgo_export.o $WORK/runtime/cgo/_obj/cgo.cgo2.o $WORK/runtime/cgo/_obj/gcc_fatalf.o $WORK/runtime/cgo/_obj/gcc_libinit.o $WORK/runtime/cgo/_obj/gcc_linux_arm.o $WORK/runtime/cgo/_obj/gcc_setenv.o $WORK/runtime/cgo/_obj/gcc_util.o $WORK/runtime/cgo/_obj/gcc_arm.o -r /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/libgcc.a --build-id=none
# _/home/nick/demo/cgodemo/GoWithC/binding
Using built-in specs.
COLLECT_GCC=arm-poky-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/lto-wrapper
Target: arm-poky-linux-gnueabi
Configured with: /home/nick/yocto-build/build/tmp/work-shared/gcc-4.9.1-r0/gcc-4.9.1/configure --build=i686-linux --host=i686-pokysdk-linux --target=arm-poky-linux-gnueabi --prefix=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr --exec_prefix=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr --bindir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --sbindir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --libexecdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi --datadir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share --sysconfdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/etc --sharedstatedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/com --localstatedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/var --libdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi --includedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/include --oldincludedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/include --infodir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share/info --mandir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=arm-poky-linux-gnueabi- --without-local-prefix --enable-target-optspace --enable-lto --enable-libssp --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=gnu --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global --with-gxx-include-dir=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/include/c++/4.9.1 --with-build-time-tools=/home/nick/yocto-build/build/tmp/sysroots/i686-linux/usr/arm-poky-linux-gnueabi/bin --with-sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi --with-build-sysroot=/home/nick/yocto-build/build/tmp/sysroots/overo --enable-poison-system-directories --with-mpfr=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --with-mpc=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --enable-nls --with-arch=armv7-a
Thread model: posix
gcc version 4.9.1 (GCC) 
COMPILER_PATH=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/
LIBRARY_PATH=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/lib/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/
COLLECT_GCC_OPTIONS='-I' '/home/nick/demo/cgodemo/GoWithC/binding' '-fPIC' '-marm' '-pthread' '-fmessage-length=0' '-o' '/tmp/go-build065055181/_/home/nick/demo/cgodemo/GoWithC/binding/_obj/_cgo_.o' '-v' '-pie' '-march=armv7-a' '-mtls-dialect=gnu'
 /opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/collect2 -plugin /opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/liblto_plugin.so -plugin-opt=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccO4wdgY.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi --build-id --eh-frame-hdr --hash-style=gnu -dynamic-linker /lib/ld-linux.so.3 -X -m armelf_linux_eabi -pie -o $WORK/_/home/nick/demo/cgodemo/GoWithC/binding/_obj/_cgo_.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/Scrt1.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/crti.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/crtbeginS.o -L/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1 -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/lib -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1 -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib $WORK/_/home/nick/demo/cgodemo/GoWithC/binding/_obj/_cgo_main.o $WORK/_/home/nick/demo/cgodemo/GoWithC/binding/_obj/_cgo_export.o $WORK/_/home/nick/demo/cgodemo/GoWithC/binding/_obj/binding.cgo2.o -lgcc --as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s --no-as-needed /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/crtendS.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/crtn.o
# _/home/nick/demo/cgodemo/GoWithC/binding
Using built-in specs.
COLLECT_GCC=arm-poky-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/lto-wrapper
Target: arm-poky-linux-gnueabi
Configured with: /home/nick/yocto-build/build/tmp/work-shared/gcc-4.9.1-r0/gcc-4.9.1/configure --build=i686-linux --host=i686-pokysdk-linux --target=arm-poky-linux-gnueabi --prefix=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr --exec_prefix=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr --bindir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --sbindir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --libexecdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi --datadir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share --sysconfdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/etc --sharedstatedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/com --localstatedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/var --libdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi --includedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/include --oldincludedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/include --infodir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share/info --mandir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=arm-poky-linux-gnueabi- --without-local-prefix --enable-target-optspace --enable-lto --enable-libssp --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=gnu --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global --with-gxx-include-dir=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/include/c++/4.9.1 --with-build-time-tools=/home/nick/yocto-build/build/tmp/sysroots/i686-linux/usr/arm-poky-linux-gnueabi/bin --with-sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi --with-build-sysroot=/home/nick/yocto-build/build/tmp/sysroots/overo --enable-poison-system-directories --with-mpfr=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --with-mpc=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --enable-nls --with-arch=armv7-a
Thread model: posix
gcc version 4.9.1 (GCC) 
COMPILER_PATH=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/
LIBRARY_PATH=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/lib/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/
COLLECT_GCC_OPTIONS='-I' '/home/nick/demo/cgodemo/GoWithC/binding' '-fPIC' '-marm' '-pthread' '-fmessage-length=0' '-o' '/tmp/go-build065055181/_/home/nick/demo/cgodemo/GoWithC/binding/_obj/_all.o' '-v' '-nostdlib' '-march=armv7-a' '-mtls-dialect=gnu'
 /opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/collect2 -plugin /opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/liblto_plugin.so -plugin-opt=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccmhwzS1.res --sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi --build-id --eh-frame-hdr --hash-style=gnu -dynamic-linker /lib/ld-linux.so.3 -X -m armelf_linux_eabi -o $WORK/_/home/nick/demo/cgodemo/GoWithC/binding/_obj/_all.o -L/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1 -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/lib -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1 -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib $WORK/_/home/nick/demo/cgodemo/GoWithC/binding/_obj/_cgo_export.o $WORK/_/home/nick/demo/cgodemo/GoWithC/binding/_obj/binding.cgo2.o -r /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/libgcc.a --build-id=none
# command-line-arguments
HEADER = -H5 -T0x11000 -D0x0 -R0x1000
searching for runtime.a in $WORK/runtime.a
searching for math.a in $WORK/math.a
 0.00 deadcode
 0.03 pclntab=259106 bytes, funcdata total 70688 bytes
 0.03 dodata
 0.06 reloc
 0.07 asmb
 0.08 datblk
 0.08 sym
 0.08 elfsym
 0.08 symsize = 44192
 0.09 symsize = 44448
 0.09 dwarf
 0.09 symsize = 44448
 0.12 dwarf pass 2.
 0.14 header
host link: "arm-poky-linux-gnueabi-gcc" "-marm" "-gdwarf-2" "-o" "/tmp/go-build065055181/command-line-arguments/_obj/exe/a.out" "-rdynamic" "/tmp/go-link-289553406/000000.o" "/tmp/go-link-289553406/000001.o" "/tmp/go-link-289553406/go.o" "-v" "-v" "-lpthread"
Using built-in specs.
COLLECT_GCC=arm-poky-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/lto-wrapper
Target: arm-poky-linux-gnueabi
Configured with: /home/nick/yocto-build/build/tmp/work-shared/gcc-4.9.1-r0/gcc-4.9.1/configure --build=i686-linux --host=i686-pokysdk-linux --target=arm-poky-linux-gnueabi --prefix=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr --exec_prefix=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr --bindir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --sbindir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --libexecdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi --datadir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share --sysconfdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/etc --sharedstatedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/com --localstatedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/var --libdir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi --includedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/include --oldincludedir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/include --infodir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share/info --mandir=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=arm-poky-linux-gnueabi- --without-local-prefix --enable-target-optspace --enable-lto --enable-libssp --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=gnu --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global --with-gxx-include-dir=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/include/c++/4.9.1 --with-build-time-tools=/home/nick/yocto-build/build/tmp/sysroots/i686-linux/usr/arm-poky-linux-gnueabi/bin --with-sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi --with-build-sysroot=/home/nick/yocto-build/build/tmp/sysroots/overo --enable-poison-system-directories --with-mpfr=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --with-mpc=/home/nick/yocto-build/build/tmp/sysroots/i686-nativesdk-pokysdk-linux --enable-nls --with-arch=armv7-a
Thread model: posix
gcc version 4.9.1 (GCC) 
COMPILER_PATH=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/
LIBRARY_PATH=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/lib/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/:/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/
COLLECT_GCC_OPTIONS='-marm' '-gdwarf-2' '-o' '/tmp/go-build065055181/command-line-arguments/_obj/exe/a.out' '-rdynamic' '-v' '-v' '-march=armv7-a' '-mtls-dialect=gnu'
 /opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/collect2 -plugin /opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/liblto_plugin.so -plugin-opt=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccst3WgX.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi --build-id --eh-frame-hdr --hash-style=gnu -export-dynamic -dynamic-linker /lib/ld-linux.so.3 -X -m armelf_linux_eabi -o $WORK/command-line-arguments/_obj/exe/a.out /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/crt1.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/crti.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/crtbegin.o -L/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1 -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/lib -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1 -L/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib /tmp/go-link-289553406/000000.o /tmp/go-link-289553406/000001.o /tmp/go-link-289553406/go.o -lpthread -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/arm-poky-linux-gnueabi/4.9.1/crtend.o /opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/crtn.o
 0.17 cpu time
43095 symbols
31912 liveness data

@minux It's essentially the same information, I was reading the arm linking code in the go src and I don't think it ever consults GCC for that information?

@ianlancetaylor
Copy link
Member

In your case the Go linker is simply running arm-poky-linux-gnueabi-gcc and trusting that it will do the right thing. The Go linker doesn't need to consult GCC, it is actually running GCC.

@ianlancetaylor
Copy link
Member

The output of GCC -dumpspecs shows that your compiler will only use ld-linux-armhf.so.3 when the -mfloat-abi=hard option is used. You need to arrange for your Go code to pass that option to the external linker. The easiest way to do that is to add #cgo LDFLAGS: -mfloat-abi=hard to your import "C" comment. You probably want to also add #cgo CFLAGS: -mfloat-abi=hard.

Closing this because I don't think Go can do any better. Please feel free to reopen if you think there is something we can do.

@17twenty
Copy link
Author

17twenty commented Sep 3, 2015

@ianlancetaylor Yeah I think that makes sense, I wasn't aware of that requirement but that's great. This ticket should stand as a useful resource for others at least!

Can confirm that adding // #cgo LDFLAGS: -mfloat-abi=hard solved the issue for my use-case as seen below:

arm-poky-linux-gnueabi-readelf Foo_ARM -a | grep ld-  [ 4] .note.gnu.build-i NOTE            00008208 000208 000024 00   A  0   0  4
      [Requesting program interpreter: /lib/ld-linux-armhf.so.3]

@dankm
Copy link

dankm commented Oct 23, 2015

I think the root of this issue is that go doesn't honour the whole $CC environment variable. OpenEmbedded (poky) sets the CC variable to the whole command needed to compile for a given target. Its compiler and linker binaries are generic, and need to be told about their target platforms. On my system CC is:

CC="arm-poky-linux-gnueabi-gcc -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/oe/build/tmp-glibc/sysroots/wandboard"

but when go runs it only runs arm-poky-linux-gnueabi-gcc for linking. Is that the intended behaviour, or is this this a bug?

@ianlancetaylor
Copy link
Member

That is a bug. But it's not this bug. Please open a new issue with a test case. Thanks.

@golang golang locked and limited conversation to collaborators Oct 24, 2016
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