cgo external linking mode on BSD - testers wanted

64 views
Skip to first unread message

Russ Cox

unread,
Mar 8, 2013, 11:29:46 PM3/8/13
to golang-dev
I've been working on implementing an "external linking" mode for cgo-using programs. In this mode the final linking is done by gcc, as an extra step after 6l has written a .o file containing all the Go code.

It now works on linux/amd64 and linux/386. My guess is that it also works on other ELF systems, in particular the BSDs, but I don't have any BSD systems on which to test. If you do and you're willing to spend a few minutes running the test, that'd be very helpful.

1. Open src/cmd/6l/obj.c or src/cmd/8l/obj.c and look for the error string "cannot use -hostobj". Add your system to the case list on the next line that right now only has case Hlinux.

2. cd $GOROOT/src; ./all.bash. If this fails, something was probably wrong before step 1.

3. go test -ldflags -hostobj ../misc/cgo/test   (the actual test)

4. If the test in step 3 passes, send a CL with your change to obj.c, enabling the -hostobj mode for that system.

Thanks.
Russ

Devon H. O'Dell

unread,
Mar 9, 2013, 10:14:00 AM3/9/13
to Russ Cox, golang-dev
2013/3/8 Russ Cox <r...@golang.org>:
> I've been working on implementing an "external linking" mode for cgo-using
> programs. In this mode the final linking is done by gcc, as an extra step
> after 6l has written a .o file containing all the Go code.
>
> It now works on linux/amd64 and linux/386. My guess is that it also works on
> other ELF systems, in particular the BSDs, but I don't have any BSD systems
> on which to test. If you do and you're willing to spend a few minutes
> running the test, that'd be very helpful.

FreeBSD deadlocks when running the test. Not sure what to do to debug
further (if someone else isn't already).

--dho

Maxim Khitrov

unread,
Mar 9, 2013, 10:23:52 AM3/9/13
to Devon H. O'Dell, Russ Cox, golang-dev
Same here (FreeBSD 9.0-RELEASE-p5 amd64):

*** Test killed: ran too long (10m0s).
FAIL _/root/go/misc/cgo/test 600.003s

- Max

Steve McCoy

unread,
Mar 9, 2013, 11:07:38 AM3/9/13
to golan...@googlegroups.com, Devon H. O'Dell, Russ Cox
Hmm, yeah, something's rotten in the state of FreeBSD. I rebuilt and retested my CLs on 9.1-RELEASE, and it still works on both amd64 and i386. Then, I pulled together an 8.3-RELEASE-p4 i386 system and got a segv:


% go test -ldflags -hostobj ../misc/cgo/test
SIGSEGV: segmentation violation
PC=0x28278219


goroutine 1 [chan receive]:
testing.RunTests(0x81410ac, 0x81b1ea0, 0x1a, 0x1a, 0x1, ...)
/home/s/go/src/pkg/testing/testing.go:427 +0x69c
testing.Main(0x81410ac, 0x81b1ea0, 0x1a, 0x1a, 0x81af200, ...)
/home/s/go/src/pkg/testing/testing.go:358 +0x66
main.main()
_/home/s/go/misc/cgo/test/_test/_testmain.go:95 +0x7e

goroutine 2 [syscall]:

goroutine 4 [runnable]:
testing.tRunner(0x38a660c0, 0x81b1ea0)
/home/s/go/src/pkg/testing/testing.go:329
created by testing.RunTests
/home/s/go/src/pkg/testing/testing.go:426 +0x681
eax     0xbf7fea4f
ebx     0x2830bdb8
ecx     0x281ef290
edx     0xc
edi     0x81bfe20
esi     0x81bfe20
ebp     0xbf7fe9f8
esp     0xbf7fe980
eip     0x28278219
eflags  0x10292
cs      0x33
fs      0x3b
gs      0x1b
FAIL _/home/s/go/misc/cgo/test 0.024s
Reply all
Reply to author
Forward
0 new messages