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: iOS project won't compile with framework built by gomobile #32918

Open
ibigbug opened this issue Jul 3, 2019 · 10 comments

Comments

@ibigbug
Copy link

@ibigbug ibigbug commented Jul 3, 2019

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

$ go version
go version go1.12.6 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/myname/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/myname/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/opt/go/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/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/cy/b0lrq2m55js29jlf_hhm4xtc0000gn/T/go-build880588199=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I created a go package and used gomobile to bind it for iOS:

gomobile bind -v  -target=ios mypackage

And then referenced the framework in my iOS project

Then complied the iOS project

What did you expect to see?

The project should compile

What did you see instead?

error messge

ld: in /PATH_TO_THE_FRAMEWORK(go.o), building for iOS, but linking in object file (/PATH_TO_THE_FRAMEWORK(go.o)) built for , for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@gopherbot gopherbot added this to the Unreleased milestone Jul 3, 2019
@gopherbot gopherbot added the mobile label Jul 3, 2019
@ibigbug ibigbug changed the title x/mobile: x/mobile: iOS project won't compile with framework built by gomobile Jul 3, 2019
@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Jul 3, 2019

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Jul 3, 2019

Then complied the iOS project

Please provide more concrete steps to reproduce the failure. What commands did you run to compile the project? Which command specifically produced the observed error message?

@steeve

This comment has been minimized.

Copy link
Contributor

@steeve steeve commented Jul 3, 2019

Is the problem in Xcode or gomobile build?
@ibigbug, can you please provide a sample project ?

cc @eliasnaur

@ibigbug

This comment has been minimized.

Copy link
Author

@ibigbug ibigbug commented Jul 3, 2019

Thanks guys for prompt reply.

I created a sample reproduce here https://github.com/ibigbug/SampleGomobile and put the steps in the README file.

A bit more information might be helpful, I'm using the latest Xcode beta. and it worked with an older version of gomobile, it compiles, but output of that version of gomobile doesn't have bitcode, so I upgraded to the latest gomobile and see this issue.

@ibigbug

This comment has been minimized.

Copy link
Author

@ibigbug ibigbug commented Jul 5, 2019

ping @steeve @bcmills

I'm using buildmode with c-archive to workaround this, but would be great to know how to fix this

@bcmills bcmills removed the WaitingForInfo label Jul 8, 2019
@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Jul 8, 2019

@ibigbug, this issue has the help wanted label because the solution is not obvious to me, and I don't know of anyone on the Go project who has the available bandwidth to look into it.

@steeve

This comment has been minimized.

Copy link
Contributor

@steeve steeve commented Jul 9, 2019

I believe this is linked to golang/mobile@9487ef5

You can either:

  • revert that commit (or jump before it)
  • try go 1.13, which this commit requires (because it has the bitcode commits)
@ibigbug

This comment has been minimized.

Copy link
Author

@ibigbug ibigbug commented Jul 20, 2019

thanks @steeve

Using go1.13beta is and manually passing CGO_FLAGS with -fembed-bitcode worked for me.

Though I'm building c-archive directly via go build, I haven't tried gomobile again, but I assume it would also work.

@ibigbug

This comment has been minimized.

Copy link
Author

@ibigbug ibigbug commented Jul 21, 2019

I'm trying to switch back to standard gomobile, however I don't seem to find doc saying how use a particular go version for gomobile.

I tried:

$ gomobile version
gomobile version unknown: binary is out of date, re-install it

$ go1.13beta1 get golang.org/x/mobile/cmd/gomobile

$ gomobile init

$ gomobile version
gomobile version unknown: binary is out of date, re-install it

Can someone point me to a way to upgrade go version for gomoible?

Found similar one #24389

@ibigbug

This comment has been minimized.

Copy link
Author

@ibigbug ibigbug commented Jul 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.