Skip to content

Does cgo supported -march=armv7-a on android NDK? #27045

@liuerhu31

Description

@liuerhu31

Please answer these questions before submitting your issue. Thanks!
go version go1.10.3 linux/amd64

What version of Go are you using (go version)?

go version go1.10.3 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="arm"
GOBIN="/home/liueh/go1.10.3/go/bin"
GOCACHE="/home/liueh/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="android"
GOPATH="/home/liueh/samba/gobuild"
GORACE=""
GOROOT="/home/liueh/go1.10.3/go"
GOTMPDIR=""
GOTOOLDIR="/home/liueh/go1.10.3/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
GOARM="7"
CC="/home/liueh/samba/android_toolchain/bin/arm-linux-androideabi-gcc"
CXX="/home/liueh/samba/android_toolchain/bin/arm-linux-androideabi-g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2 -march=armv7-a"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -marm -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build631972627=/tmp/go-build -gno-record-gcc-switches"

What did you do?

i'm trying to cross compiler my code on android NDK,and my code reply on a armv7-a library.
then,i got the warning at below:
./../arm-linux-androideabi/bin/ld: warning: cannot scan executable section 1 of /tmp/go-link-316549340/go.o for Cortex-A8 erratum because it has no mapping symbols.

in additional, i find that just add -march=armv7-a to CGO_CFLAGS without depend on the third-party armv7-a library which also get that warning above.

this is demo to reproduce this issue:

1. code:

package main
/*
#cgo LDFLAGS:
//libtest.so is build as: arm-linux-androideabi-gcc -march=armv7-a -shared -o libtest.so test.c
//#cgo LDFLAGS: -L ${SRCDIR}/.. -ltest
*/
import "C"

func main(){}

2. shell:

#!/bin/bash

export GOROOT=/home/liueh/go1.10.3/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN

##set go path
export GOPATH=/home/liueh/samba/gobuild
##set compiler
export CC="/home/liueh/samba/android_toolchain/bin/arm-linux-androideabi-gcc"
export CXX="/home/liueh/samba/android_toolchain/bin/arm-linux-androideabi-g++"

#export CC="/opt/android-ndk-r9/bin/arm-linux-androideabi-gcc"
#export CXX="/opt/android-ndk-r9/bin/arm-linux-androideabi-g++"

export CGO_CFLAGS="-g -O2 -march=armv7-a"

export GOARCH="arm"
export GOOS="android"
export GOARM=7
export CGO_ENABLED="1"

go build -o gotest ./src/tovs.go

What did you see instead?

what else can i do? thanks for any advice.

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