Anyone interested in darwin/arm (iOS) port?

160 views
Skip to first unread message

minux

unread,
Dec 29, 2011, 11:49:38 AM12/29/11
to golan...@googlegroups.com
Hi all,
     I have been working on porting Go (5g) to darwin/arm (aka. iOS) platform.
Now I have a working 5c/5g and 5l. pkg/runtime is mostly working. It already passed
several pkg tests. For example, goroutine is fully functional now.
     Now I encountered a weird bug, it seems totally random. Sometimes, a test program
(pkg/time's) will PASS, sometimes it will receive SIGILL and sometimes it will panic like
this:
panic: interface conversion: interface is *fmt.ss, not *fmt.pp

goroutine 1 [running]:
fmt.newPrinter(0x107150f0, 0x8)
    /private/var/mobile/build/goios.hg/src/pkg/fmt/print.go:126 +0x50
It seems there have been a buffer overflow or something like that? I managed to get a
register dump on receiving SIGILL, and it turns out that LR isn't right, so I think the program
might have run away.
      I can't use gdb, because gdb is totally confused by the go thread and signal handling
code, and there isn't dtrace on iOS, nor is any emulator.
     Dose any one has suggestion on how to track this sort of bug? And any one interested in
iOS port?


Best regards.
minux

Mikkel Krautz

unread,
Dec 29, 2011, 2:37:37 PM12/29/11
to minux, golan...@googlegroups.com

I'm interested.

Is the source available anywhere, to play with?

Mikkel

minux

unread,
Dec 29, 2011, 6:42:38 PM12/29/11
to Mikkel Krautz, golan...@googlegroups.com
On Fri, Dec 30, 2011 at 3:37 AM, Mikkel Krautz <mik...@krautz.dk> wrote:
I'm interested.

Is the source available anywhere, to play with?
Sure, is at: https://bitbucket.org/minux/goios/  branch ios

Current status:
1, everything compiled fine.
2, trivial Go programs and C programs works (see 3 for an example).
3, test/bench/shoutout/*.go works (except one: regex-dna), but beware that some of them might take
   a long long time to complete due to the unoptimized 6g compiler.
4, some pkg test passed.
5, but major go cmds godoc/gofmt etc. doesn't working yet. And because of this, I can't build in tip of default
  branch (for I don't have cmd/go), my branch is based on rev 10983:9bccb4a32e4a.

Notes:
1, I only tested compilation on iPad1, with iphone-gcc-4.2.1 (build 5555).
2, you will need some Mac OS X header files, notably /usr/include/i386 folder and /usr/include/sys/ptrace.h,
so if the compilation failed for missing headers, don't panic, just copy them from Mac OS X :)
(but don't copy the ARM specific ones, you know what I'm talking about~~)
3, define these environment variables before build:
MAKEFLAGS=-j1 # default is -j4, it will trigger iPad reboot
GOARCH="arm" # Can't be inferred now, because `uname -m` doesn't return something like 'arm*', but 'iPad1,1'
GOOS="darwin"
4, feel free to ask me about anything about this port :)

Best regards,
minux

Den Shabalin

unread,
Dec 29, 2011, 6:33:41 PM12/29/11
to golang-nuts
Hi,
As for me Go on iOS sounds amazing.
It'll make mobile cross-platform development in Go possible.

minux

unread,
Dec 29, 2011, 6:58:42 PM12/29/11
to Den Shabalin, golang-nuts
On Fri, Dec 30, 2011 at 7:33 AM, Den Shabalin <den.sh...@gmail.com> wrote:
Hi,
As for me Go on iOS sounds amazing.
It'll make mobile cross-platform development in Go possible.
Yes, I'd like that too.
But, it can't do GUI on iOS (in the near future, IMHO)... As far as I can tell, cgo on Mac OS X still can't interface
obj-c code?

Also, the ARM backend of the compiler needs some polish...  The peephole optimizer missed some obvious
optimizations.

minux

unread,
Dec 30, 2011, 3:57:19 PM12/30/11
to golan...@googlegroups.com
On Fri, Dec 30, 2011 at 12:49 AM, minux <minu...@gmail.com> wrote:
     Now I encountered a weird bug, it seems totally random. Sometimes, a test program
(pkg/time's) will PASS, sometimes it will receive SIGILL and sometimes it will panic like
this:
panic: interface conversion: interface is *fmt.ss, not *fmt.pp

goroutine 1 [running]:
fmt.newPrinter(0x107150f0, 0x8)
    /private/var/mobile/build/goios.hg/src/pkg/fmt/print.go:126 +0x50
It seems there have been a buffer overflow or something like that? I managed to get a
register dump on receiving SIGILL, and it turns out that LR isn't right, so I think the program
might have run away.
This weird bug is trace to have something with the icache flush assembly code. Hope I can
figure out the bugfix soon.

The test case in test/ken/litfun.go helps me a lot in tracing the bug. Thanks ken :)

minux

unread,
Dec 30, 2011, 5:38:13 PM12/30/11
to golan...@googlegroups.com
Lasted status report: the weird bug is fixed. cgo/gofmt/go is working now.
Many pkg tests have been passed. (I can't insist announcing this before the test completed,
because the tests take so looong).

Check out the latest ios branch from https://bitbucket.org/minux/goios/ and try it yourself.
I think it's mostly working now. But due to hardware problems, I can only test this on my
friend's iPad 1 which runs the iOS version 4.2.1 (quite old, so I'm not certain if it can work
on later iOS versions).

Any alpha testers welcome. (Detailed instruction on how to build this is in an earlier post
of this thread. Please note that building this may take some efforts, I'll fix that soon.)


Regards,
minux

Den Shabalin

unread,
Jan 2, 2012, 7:32:45 PM1/2/12
to golang-nuts
I might be wrong here but isn't it possible to wrap objective-c code
in plain c wrapper like:

@interface myclass {
}
- (t1)foo:(t2)a bar:(t3)b
@end

t1 myclass_foo_bar_(myclass *this, t2 a, t3 b) {
return [this foo:a bar:b]
}

Thanks for great work!


On Dec 30 2011, 1:58 am, minux <minux...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages