Skip to content

Cross-compiling with cgo for ARMv7 fails #13377

Closed
@gjstrange

Description

@gjstrange

We are using Go on a ARM335x/Linux board very similar to the BeagleBone black, but the cross compile fails if it involves mixed C and Go code and cgo.

Background: Using go version 1.5.1. Host is Ubunutu 15.04 running in a VM on a Mac. Target settings:
GOOS= linux
GOARCH=arm
GOARM=7

CC, CXX, etc. are also set to the cross compiler gcc tools.

The error reported is:

`# runtime/cgo
In file included from /opt/yogurt/AM335x-PD15.1.1/sysroots/cortexa8t2hf-vfp-neon-phytec-linux-gnueabi/usr/include/features.h:389:0,
from /opt/yogurt/AM335x-PD15.1.1/sysroots/cortexa8t2hf-vfp-neon-phytec-linux-gnueabi/usr/include/errno.h:28,
from /usr/local/go/src/runtime/cgo/cgo.go:50:
/opt/yogurt/AM335x-PD15.1.1/sysroots/cortexa8t2hf-vfp-neon-phytec-linux-gnueabi/usr/include/gnu/stubs.h:7:29: fatal error: gnu/stubs-soft.h: No such file or directory

include <gnu/stubs-soft.h>

                         ^

compilation terminated.`

Some research showed that the problem stemmed from incorrect compiler flags. The ARMv7 processor (TI AM3359 Cortex A8 in this case), uses hardware hardware floating point, so the following flags need to be set:

"-mthumb-interwork", "-mfloat-abi=hard", "-mfpu=neon"

It also should link against /lib/ld-linux-armhf.so.3, but links against /lib/ld-linux.so.3 instead.

We have a personal branch of Go now that fixes the problem, though we are new to Go, so the change may not be well done.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions