Cannot build for arm64

Issue #7 resolved
Keith Lea created an issue

Hello again :)

As of this Sunday, Apple is now requiring all apps deployed to the App Store contain a slice for arm64. I'm trying to build the Go-iOS toolchain for arm64 but not having any success. Steps to reproduce:

  1. Check out goios

  2. Modify clangwrap.sh to pass arm64 to clang: exec "$CLANG" -arch arm64 -isysroot "$SDK_PATH" "$@"

  3. Build Go toolchain GOARM=7 CGO_ENABLED=1 GOARCH=arm CC_FOR_TARGET=`pwd`/../misc/ios/clangwrap.sh CXX_FOR_TARGET=`pwd`/../misc/ios/clangwrap.sh ./make.bash

  4. Make a hello world app and run go build

  5. Run lipo -info tool on generated binary: shows Non-fat file: tmp is architecture: armv7

Comments (15)

  1. Keith Lea reporter

    I found a relevant patch:

    Teach cmd/dist about GOARCH=arm64

    However after applying that patch, the build fails:

    ##### Building compilers and Go bootstrap tool for host, darwin/amd64.
    lib9
    libbio
    liblink
    cmd/gc
    cmd/6l
    cmd/7l
    go tool dist: opendir /Users/.../goios-arm64/src/cmd/7l: No such file or directory
    
  2. minux repo owner

    Go doesn't support arm64 yet. The Linux port is in the works (it is in final stages now). I will start darwin/arm64 port as soon as that project finishes.

  3. Keith Lea reporter

    Ahh I see. Is that an easy port since you've already done the arm port? Or is arm64 very different?

  4. minux repo owner

    It will not be as easy as the arm port because the linux/arm64 port doesn't support cgo yet. (And cgo is not in their goals.)

    I first need to get cgo working for linux/arm64 (and yes, I also wrote cgo for linux/arm), but that needs more time.

    The actual port to darwin/arm64 shouldn't be too difficult if linux/arm64 is ready.

    You can monitor the progress of the linux/arm64 port here: https://github.com/4ad/go

  5. minux repo owner

    The ios64 branch is the work in progress for this issue.

    Basic binaries are running fine now.

  6. Jay Vaughan-Limberk

    Greetings minux, and thanks for the great work on goios. I plan on using Go code on iOS, and so to that end I set up a ready-made XCode harness, set up to build a moderately large Go package (ipfs) as a test-bed. At the moment I do not have it configured for arm64 - so ios64 is in a productive/usable status? I will report back...

    EDIT: ipfsios here: https://github.com/seclorum/ipfs-on-ios.git

  7. minux repo owner

    The port has already upstreamed, so you can use the tip version of the official Go for both 32 and 64 bit iOS development.

    Or you can wait for Go 1.5, to be released in 3 months. There will be official gomobile build tool for iOS and android.

  8. Jay Vaughan-Limberk

    Thanks for the info - will take it into account. I've been able to build ipfs in the meantime ..

  9. James Schofield

    This is great. I was able to build an armv7/arm64 universal library by working off Keith's posts. :)

    Only hitting one snag in getting my app to validate with iTunes. Apparently the call to exc_server here is a problem: https://github.com/golang/go/blob/989f0ee80a57c7c57fe4ae238d14cbffe8f9fd87/src/runtime/cgo/gcc_signal_darwin_armx.c#L173

    Error: iTunes Store operation failed. Your app contains non-public API usage. This app references non-public symbols ... exc_server.

    Can we work around that?

  10. minux repo owner

    You need to rebuild Go with -tags lldb (GOARCH=arm64 GOOS=darwin CGO_ENABLED=1 go install -a -v std), I will report this problem upstream.

  11. Log in to comment