Compiling on iOS

Issue #1 resolved
Charley Peng created an issue

Hi I was wondering the status of this fork. I'm trying to compile this on iOS (using 6.1 SDK on a iOS 8.1 device) however I have come across an error and was wondering whether you could advise. (I'm using LLVM+Clang, clang version 3.5.0 (trunk) Target: armv7-apple-darwin14.0.0)

/var/mobile/goios/src root#  GOARM=7 GOARCH=arm CC_FOR_TARGET=`pwd`/../misc/ios/clangwrap.sh          CXX_FOR_TARGET=`pwd`/../misc/ios/clangwrap.sh ./make.bash
##### Building C bootstrap tool.
cmd/dist

##### Building compilers and Go bootstrap tool for host, darwin/arm.
lib9
libbio
liblink
cmd/gc
cmd/5l
cmd/5a
cmd/5g
runtime
errors
sync/atomic
sync
io
unicode
unicode/utf8
unicode/utf16
bytes
math
strings
strconv
bufio
sort
container/heap
encoding/base64
syscall
time
os
reflect
fmt
encoding
encoding/json
flag
path/filepath
path
io/ioutil
log
regexp/syntax
regexp
go/token
go/scanner
go/ast
go/parser
os/exec
os/signal
net/url
text/template/parse
text/template
go/doc
go/build
cmd/go
fatal error: runtime: bsdthread_register error

runtime stack:
runtime.throw(0x26eb48, 0x21)
        /var/mobile/goios/src/runtime/panic.go:492 +0x8c fp=0x49dfe0 sp=0x49dfd4
runtime.goenvs()
        /var/mobile/goios/src/runtime/os1_darwin.go:69 +0xac fp=0x49dffc sp=0x49dfe0
runtime.schedinit()
        /var/mobile/goios/src/runtime/proc1.go:123 +0x58 fp=0x49e020 sp=0x49dffc
runtime.rt0_go(0x4, 0x49e070, 0x4, 0x49e14c, 0x49e17f, 0x49e185, 0x49e188, 0x0, 0x49e18c, 0x49e1ca, ...)
        /var/mobile/goios/src/runtime/asm_arm.s:70 +0xa8 fp=0x49e060 sp=0x49e020

Comments (3)

  1. minux repo owner

    (I also replied via email, but as my comment hasn't appeared yet, I will add slightly reformatted version of it here just in case)

    The port should be fully working and I'm upstreamming the port right now.

    I haven't tried to compile it natively on iOS 8 (my test environment is very out-dated, running iOS 5.1.1). I think the go_bootstrap problem is either due to the kernel changed bsdthread_register syscall (fairly unlikely), or there might be an inserted dylib that uses libc, which will register its own bsdthread handler that will conflict with Go's.

    That being said, I do get good results from people on recent iOS version running Go programs cross-compiled with cgo enabled on OS X. Perhaps you can try cross compiling the port. Just follow the misc/ios/README file and adjust misc/ios/clangwrap.sh as necessary. The main work flow supported by this port, esp. after the upstreamming, will be cross compiling from OS X: because we can't require the user to jailbreak the device to use an official Go port. I will maintain the additional patches needed for native compiling here, and I will debug the problem if I upgraded my test device.

    Then you can build whatever go program to run on iOS, just make sure to use external linking if your code is not using cgo. (pass -ldflags "-linkmode external" to go build)

    Thanks.

  2. Log in to comment