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

x/mobile: gomobile build fails building package for arm64 if package contains cpp source code #27508

Closed
tadovas opened this issue Sep 5, 2018 · 1 comment
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile
Milestone

Comments

@tadovas
Copy link

tadovas commented Sep 5, 2018

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

go version go1.11 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/tadovas/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/tadovas/work/go/openvpnv3-go-bindings"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_j/73ymsvw56v989xyfwn6q18_m0000gn/T/go-build550793449=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Trying to build the following cpp/go gist sample
gomobile build --target=ios/arm64 cpptest

What did you expect to see?

Successfully built package

What did you see instead?

gomobile: go build -tags ios cpptest failed: exit status 2
ld: warning: ignoring file $WORK/b001/_x003.o, file was built for x86_64 which is not the architecture being linked (arm64): $WORK/b001/_x003.o
Undefined symbols for architecture arm64:
"_hello", referenced from:
__cgo_f57df320d1c2_Cfunc_hello in _x002.o
(maybe you meant: __cgo_f57df320d1c2_Cfunc_hello)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The problem seems to be here:
as CGO_CFLAGS are set up, but no CGO_CXXFLAGS are defined. The possible workaround would be to call CGO_CXXFLAGS='-arch arm64' gomobile ... but it looks a bit cumbersome.

@tadovas tadovas changed the title Gomobile fails building package for arm64 if package contains cpp source code x/mobile: gomobile build fails building package for arm64 if package contains cpp source code Sep 5, 2018
@gopherbot gopherbot added this to the Unreleased milestone Sep 5, 2018
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Sep 5, 2018
@tadovas
Copy link
Author

tadovas commented Sep 14, 2018

Fixed by CL 134975.

@tadovas tadovas closed this as completed Sep 14, 2018
@golang golang locked and limited conversation to collaborators Sep 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile
Projects
None yet
Development

No branches or pull requests

2 participants