Tue Mar 10 13:11:36 2015 UTC ()
Implement cgo support for illumos.  Patches by Keith Wesolowski at Joyent.

Bump PKGREVISION.


(jperkin)
diff -r1.26 -r1.27 pkgsrc/lang/go/Makefile
diff -r1.17 -r1.18 pkgsrc/lang/go/PLIST
diff -r1.21 -r1.22 pkgsrc/lang/go/distinfo
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-doc_progs_run
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-misc_cgo_test_cthread__unix.c
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-misc_cgo_testso_cgoso.go
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-misc_cgo_testso_cgoso__unix.go
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_cmd_5l_asm.c
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_cmd_6l_asm.c
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_cmd_8l_asm.c
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_cmd_ld_data.c
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_cmd_ld_doc.go
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_cmd_ld_lib.h
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_cmd_ld_pobj.c
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_go_build_build.go
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_net_cgo__bsd.go
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_net_cgo__stub.go
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_net_cgo__unix.go
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_os_user_lookup__unix.go
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_runtime_cgo_cgo.go
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_runtime_cgo_gcc__setenv.c
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_runtime_cgo_gcc__solaris__amd64.c
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_runtime_cgo_setenv.c
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_runtime_netpoll__solaris.c
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_runtime_os__solaris.c
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_runtime_os__solaris.h
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_runtime_sys__solaris__amd64.s
diff -r0 -r1.1 pkgsrc/lang/go/patches/patch-src_runtime_thunk__solaris__amd64.s
diff -r0 -r1.3 pkgsrc/lang/go/patches/patch-src_cmd_go_build.go

cvs diff -r1.26 -r1.27 pkgsrc/lang/go/Makefile (expand / switch to unified diff)

--- pkgsrc/lang/go/Makefile 2015/02/22 13:28:30 1.26
+++ pkgsrc/lang/go/Makefile 2015/03/10 13:11:36 1.27
@@ -1,42 +1,35 @@ @@ -1,42 +1,35 @@
1# $NetBSD: Makefile,v 1.26 2015/02/22 13:28:30 tnn Exp $ 1# $NetBSD: Makefile,v 1.27 2015/03/10 13:11:36 jperkin Exp $
2 2
3.include "version.mk" 3.include "version.mk"
4 4
5DISTNAME= go${GO_VERSION}.src 5DISTNAME= go${GO_VERSION}.src
6PKGNAME= go-${GO_VERSION} 6PKGNAME= go-${GO_VERSION}
 7PKGREVISION= 1
7CATEGORIES= lang 8CATEGORIES= lang
8MASTER_SITES= https://storage.googleapis.com/golang/ 9MASTER_SITES= https://storage.googleapis.com/golang/
9PATCH_SITES= https://codereview.appspot.com/download/ 10PATCH_SITES= https://codereview.appspot.com/download/
10 11
11MAINTAINER= bsiegert@NetBSD.org 12MAINTAINER= bsiegert@NetBSD.org
12HOMEPAGE= http://golang.org/ 13HOMEPAGE= http://golang.org/
13COMMENT= The Go programming language 14COMMENT= The Go programming language
14LICENSE= modified-bsd 15LICENSE= modified-bsd
15 16
16WRKSRC= ${WRKDIR}/go 17WRKSRC= ${WRKDIR}/go
17USE_TOOLS+= bash:run perl:run pax 18USE_TOOLS+= bash:run perl:run pax
18 19
19# uses ulimit -T 20# uses ulimit -T
20BUILD_DEPENDS+= bash>=4.2nb3:../../shells/bash 21BUILD_DEPENDS+= bash>=4.2nb3:../../shells/bash
21 22
22PLIST_VARS+= cgo zsyscall 
23 
24.if ${OPSYS} == "SunOS" 
25PLIST.zsyscall= yes 
26.else 
27PLIST.cgo= yes 
28.endif 
29 
30# cgo compiles under TMPDIR 23# cgo compiles under TMPDIR
31TMPDIR?= /tmp 24TMPDIR?= /tmp
32BUILDLINK_PASSTHRU_DIRS+= ${TMPDIR} 25BUILDLINK_PASSTHRU_DIRS+= ${TMPDIR}
33 26
34# bash script may use unportable bash constructs 27# bash script may use unportable bash constructs
35CHECK_PORTABILITY_SKIP= lib/time/update.bash 28CHECK_PORTABILITY_SKIP= lib/time/update.bash
36 29
37GOROOT_FINAL= ${PREFIX}/go 30GOROOT_FINAL= ${PREFIX}/go
38INSTALLATION_DIRS= bin 31INSTALLATION_DIRS= bin
39 32
40REPLACE_BASH+= doc/articles/wiki/test.bash 33REPLACE_BASH+= doc/articles/wiki/test.bash
41REPLACE_BASH+= doc/codewalk/run 34REPLACE_BASH+= doc/codewalk/run
42REPLACE_BASH+= doc/progs/run 35REPLACE_BASH+= doc/progs/run
@@ -83,19 +76,19 @@ REPLACE_PERL+= test/errchk @@ -83,19 +76,19 @@ REPLACE_PERL+= test/errchk
83# uses /bin/rc (for Plan 9) 76# uses /bin/rc (for Plan 9)
84CHECK_INTERPRETER_SKIP+= go/include/plan9/mklibc.rc 77CHECK_INTERPRETER_SKIP+= go/include/plan9/mklibc.rc
85CHECK_INTERPRETER_SKIP+= go/src/all.rc 78CHECK_INTERPRETER_SKIP+= go/src/all.rc
86CHECK_INTERPRETER_SKIP+= go/src/clean.rc 79CHECK_INTERPRETER_SKIP+= go/src/clean.rc
87CHECK_INTERPRETER_SKIP+= go/src/make.rc 80CHECK_INTERPRETER_SKIP+= go/src/make.rc
88CHECK_INTERPRETER_SKIP+= go/src/run.rc 81CHECK_INTERPRETER_SKIP+= go/src/run.rc
89 82
90do-build: 83do-build:
91 cd ${WRKSRC}/src && env GOROOT_FINAL=${GOROOT_FINAL:Q} ${BASH} ./make.bash 84 cd ${WRKSRC}/src && env GOROOT_FINAL=${GOROOT_FINAL:Q} ${BASH} ./make.bash
92 85
93do-install: 86do-install:
94 cd ${WRKSRC} && rm -rf .hgignore .hgtags pkg/obj 87 cd ${WRKSRC} && rm -rf .hgignore .hgtags pkg/obj
95 cd ${WRKDIR} && pax -rw go ${DESTDIR}${PREFIX} 88 cd ${WRKDIR} && pax -rw go ${DESTDIR}${PREFIX}
96 find ${DESTDIR}${PREFIX}/go/src -name \*.orig -exec rm {} \; 89 find ${DESTDIR}${PREFIX}/go -name \*.orig -exec rm {} \;
97.for cmd in go gofmt 90.for cmd in go gofmt
98 cd ${DESTDIR}${PREFIX}/bin && ln -sf ../go/bin/${cmd} ${cmd} 91 cd ${DESTDIR}${PREFIX}/bin && ln -sf ../go/bin/${cmd} ${cmd}
99.endfor 92.endfor
100 93
101.include "../../mk/bsd.pkg.mk" 94.include "../../mk/bsd.pkg.mk"

cvs diff -r1.17 -r1.18 pkgsrc/lang/go/Attic/PLIST (expand / switch to unified diff)

--- pkgsrc/lang/go/Attic/PLIST 2015/02/22 13:14:09 1.17
+++ pkgsrc/lang/go/Attic/PLIST 2015/03/10 13:11:36 1.18
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1@comment $NetBSD: PLIST,v 1.17 2015/02/22 13:14:09 mspo Exp $ 1@comment $NetBSD: PLIST,v 1.18 2015/03/10 13:11:36 jperkin Exp $
2bin/go 2bin/go
3bin/gofmt 3bin/gofmt
4go/AUTHORS 4go/AUTHORS
5go/CONTRIBUTORS 5go/CONTRIBUTORS
6go/LICENSE 6go/LICENSE
7go/PATENTS 7go/PATENTS
8go/README 8go/README
9go/VERSION 9go/VERSION
10go/api/README 10go/api/README
11go/api/except.txt 11go/api/except.txt
12go/api/go1.1.txt 12go/api/go1.1.txt
13go/api/go1.2.txt 13go/api/go1.2.txt
14go/api/go1.3.txt 14go/api/go1.3.txt
@@ -505,27 +505,27 @@ go/pkg/${GO_PLATFORM}/net/smtp.a @@ -505,27 +505,27 @@ go/pkg/${GO_PLATFORM}/net/smtp.a
505go/pkg/${GO_PLATFORM}/net/textproto.a 505go/pkg/${GO_PLATFORM}/net/textproto.a
506go/pkg/${GO_PLATFORM}/net/url.a 506go/pkg/${GO_PLATFORM}/net/url.a
507go/pkg/${GO_PLATFORM}/os.a 507go/pkg/${GO_PLATFORM}/os.a
508go/pkg/${GO_PLATFORM}/os/exec.a 508go/pkg/${GO_PLATFORM}/os/exec.a
509go/pkg/${GO_PLATFORM}/os/signal.a 509go/pkg/${GO_PLATFORM}/os/signal.a
510go/pkg/${GO_PLATFORM}/os/user.a 510go/pkg/${GO_PLATFORM}/os/user.a
511go/pkg/${GO_PLATFORM}/path.a 511go/pkg/${GO_PLATFORM}/path.a
512go/pkg/${GO_PLATFORM}/path/filepath.a 512go/pkg/${GO_PLATFORM}/path/filepath.a
513go/pkg/${GO_PLATFORM}/reflect.a 513go/pkg/${GO_PLATFORM}/reflect.a
514go/pkg/${GO_PLATFORM}/regexp.a 514go/pkg/${GO_PLATFORM}/regexp.a
515go/pkg/${GO_PLATFORM}/regexp/syntax.a 515go/pkg/${GO_PLATFORM}/regexp/syntax.a
516go/pkg/${GO_PLATFORM}/runtime.a 516go/pkg/${GO_PLATFORM}/runtime.a
517go/pkg/${GO_PLATFORM}/runtime.h 517go/pkg/${GO_PLATFORM}/runtime.h
518${PLIST.cgo}go/pkg/${GO_PLATFORM}/runtime/cgo.a 518go/pkg/${GO_PLATFORM}/runtime/cgo.a
519go/pkg/${GO_PLATFORM}/runtime/debug.a 519go/pkg/${GO_PLATFORM}/runtime/debug.a
520go/pkg/${GO_PLATFORM}/runtime/pprof.a 520go/pkg/${GO_PLATFORM}/runtime/pprof.a
521go/pkg/${GO_PLATFORM}/runtime/race.a 521go/pkg/${GO_PLATFORM}/runtime/race.a
522go/pkg/${GO_PLATFORM}/sort.a 522go/pkg/${GO_PLATFORM}/sort.a
523go/pkg/${GO_PLATFORM}/strconv.a 523go/pkg/${GO_PLATFORM}/strconv.a
524go/pkg/${GO_PLATFORM}/strings.a 524go/pkg/${GO_PLATFORM}/strings.a
525go/pkg/${GO_PLATFORM}/sync.a 525go/pkg/${GO_PLATFORM}/sync.a
526go/pkg/${GO_PLATFORM}/sync/atomic.a 526go/pkg/${GO_PLATFORM}/sync/atomic.a
527go/pkg/${GO_PLATFORM}/syscall.a 527go/pkg/${GO_PLATFORM}/syscall.a
528go/pkg/${GO_PLATFORM}/testing.a 528go/pkg/${GO_PLATFORM}/testing.a
529go/pkg/${GO_PLATFORM}/testing/iotest.a 529go/pkg/${GO_PLATFORM}/testing/iotest.a
530go/pkg/${GO_PLATFORM}/testing/quick.a 530go/pkg/${GO_PLATFORM}/testing/quick.a
531go/pkg/${GO_PLATFORM}/text/scanner.a 531go/pkg/${GO_PLATFORM}/text/scanner.a
@@ -2560,26 +2560,27 @@ go/src/runtime/cgo/gcc_dragonfly_amd64.c @@ -2560,26 +2560,27 @@ go/src/runtime/cgo/gcc_dragonfly_amd64.c
2560go/src/runtime/cgo/gcc_fatalf.c 2560go/src/runtime/cgo/gcc_fatalf.c
2561go/src/runtime/cgo/gcc_freebsd_386.c 2561go/src/runtime/cgo/gcc_freebsd_386.c
2562go/src/runtime/cgo/gcc_freebsd_amd64.c 2562go/src/runtime/cgo/gcc_freebsd_amd64.c
2563go/src/runtime/cgo/gcc_freebsd_arm.c 2563go/src/runtime/cgo/gcc_freebsd_arm.c
2564go/src/runtime/cgo/gcc_linux_386.c 2564go/src/runtime/cgo/gcc_linux_386.c
2565go/src/runtime/cgo/gcc_linux_amd64.c 2565go/src/runtime/cgo/gcc_linux_amd64.c
2566go/src/runtime/cgo/gcc_linux_arm.c 2566go/src/runtime/cgo/gcc_linux_arm.c
2567go/src/runtime/cgo/gcc_netbsd_386.c 2567go/src/runtime/cgo/gcc_netbsd_386.c
2568go/src/runtime/cgo/gcc_netbsd_amd64.c 2568go/src/runtime/cgo/gcc_netbsd_amd64.c
2569go/src/runtime/cgo/gcc_netbsd_arm.c 2569go/src/runtime/cgo/gcc_netbsd_arm.c
2570go/src/runtime/cgo/gcc_openbsd_386.c 2570go/src/runtime/cgo/gcc_openbsd_386.c
2571go/src/runtime/cgo/gcc_openbsd_amd64.c 2571go/src/runtime/cgo/gcc_openbsd_amd64.c
2572go/src/runtime/cgo/gcc_setenv.c 2572go/src/runtime/cgo/gcc_setenv.c
 2573go/src/runtime/cgo/gcc_solaris_amd64.c
2573go/src/runtime/cgo/gcc_util.c 2574go/src/runtime/cgo/gcc_util.c
2574go/src/runtime/cgo/gcc_windows_386.c 2575go/src/runtime/cgo/gcc_windows_386.c
2575go/src/runtime/cgo/gcc_windows_amd64.c 2576go/src/runtime/cgo/gcc_windows_amd64.c
2576go/src/runtime/cgo/iscgo.c 2577go/src/runtime/cgo/iscgo.c
2577go/src/runtime/cgo/libcgo.h 2578go/src/runtime/cgo/libcgo.h
2578go/src/runtime/cgo/netbsd.c 2579go/src/runtime/cgo/netbsd.c
2579go/src/runtime/cgo/openbsd.c 2580go/src/runtime/cgo/openbsd.c
2580go/src/runtime/cgo/setenv.c 2581go/src/runtime/cgo/setenv.c
2581go/src/runtime/cgocall.go 2582go/src/runtime/cgocall.go
2582go/src/runtime/cgocall.h 2583go/src/runtime/cgocall.h
2583go/src/runtime/cgocallback.go 2584go/src/runtime/cgocallback.go
2584go/src/runtime/chan.go 2585go/src/runtime/chan.go
2585go/src/runtime/chan.h 2586go/src/runtime/chan.h

cvs diff -r1.21 -r1.22 pkgsrc/lang/go/Attic/distinfo (expand / switch to unified diff)

--- pkgsrc/lang/go/Attic/distinfo 2015/02/22 13:29:01 1.21
+++ pkgsrc/lang/go/Attic/distinfo 2015/03/10 13:11:36 1.22
@@ -1,7 +1,33 @@ @@ -1,7 +1,33 @@
1$NetBSD: distinfo,v 1.21 2015/02/22 13:29:01 tnn Exp $ 1$NetBSD: distinfo,v 1.22 2015/03/10 13:11:36 jperkin Exp $
2 2
3SHA1 (go1.4.2.src.tar.gz) = 460caac03379f746c473814a65223397e9c9a2f6 3SHA1 (go1.4.2.src.tar.gz) = 460caac03379f746c473814a65223397e9c9a2f6
4RMD160 (go1.4.2.src.tar.gz) = dea15b3b4c31554a47b40799f4b9a926ea760e70 4RMD160 (go1.4.2.src.tar.gz) = dea15b3b4c31554a47b40799f4b9a926ea760e70
5Size (go1.4.2.src.tar.gz) = 10921896 bytes 5Size (go1.4.2.src.tar.gz) = 10921896 bytes
 6SHA1 (patch-doc_progs_run) = 5a29fe4f91defb2e20d192850601df7cbabdac7c
 7SHA1 (patch-misc_cgo_test_cthread__unix.c) = a63f08f07713bd32e279315cca21235101ce9cd3
 8SHA1 (patch-misc_cgo_testso_cgoso.go) = ef782a6f173c814656eac0df640aedaa1a923bbc
 9SHA1 (patch-misc_cgo_testso_cgoso__unix.go) = 58e221e1ce123428a3fe6ecededf0590cbfb81ca
 10SHA1 (patch-src_cmd_5l_asm.c) = fd78203b7c92b9bbd057077671d649bac2d121ee
 11SHA1 (patch-src_cmd_6l_asm.c) = 1f244d7c760e738057b1649ed486206a6ec3812b
 12SHA1 (patch-src_cmd_8l_asm.c) = e5233a3d9b08f2ef8d809756ef7d6fc4b03303b9
 13SHA1 (patch-src_cmd_go_build.go) = f7705aa955241d3add353a144a676a58a0a1617e
6SHA1 (patch-src_cmd_go_pkg.go) = e70441f3fdf312eb389e4dd5408c207a4d4b8350 14SHA1 (patch-src_cmd_go_pkg.go) = e70441f3fdf312eb389e4dd5408c207a4d4b8350
 15SHA1 (patch-src_cmd_ld_data.c) = 96181bac03333f7bc5293ab9ddbd68bb9174ed47
 16SHA1 (patch-src_cmd_ld_doc.go) = 000447f5a5862358a85a7510dc92195494972e26
 17SHA1 (patch-src_cmd_ld_lib.h) = e6aa8b9520e1b75f435e179e5ea4f0ef738621f4
 18SHA1 (patch-src_cmd_ld_pobj.c) = eaf67d6bc4f9ba835893f9d8c2d36941ff84933d
7SHA1 (patch-src_crypto_x509_root__unix.go) = c933f334da1c8de48a06d23abd12da01f73776e6 19SHA1 (patch-src_crypto_x509_root__unix.go) = c933f334da1c8de48a06d23abd12da01f73776e6
 20SHA1 (patch-src_go_build_build.go) = b68bc557e7b48877889c63070e9cb9d8360f40f5
 21SHA1 (patch-src_net_cgo__bsd.go) = 4678fccd6956300ce55343965334fc3881383bbc
 22SHA1 (patch-src_net_cgo__stub.go) = cf373587745d68e556dadf3a61956b489b4f420a
 23SHA1 (patch-src_net_cgo__unix.go) = cebe897ab624aaf52bebc50d12a045d6b4ea2bc6
 24SHA1 (patch-src_os_user_lookup__unix.go) = 861cf9b2b64bc314b6ee8e11411245e214717515
 25SHA1 (patch-src_runtime_cgo_cgo.go) = 9cc88b35d12e0d52e76495e04f7fce2b78af08d5
 26SHA1 (patch-src_runtime_cgo_gcc__setenv.c) = c9614b76d71e84ad46b2ce785580fdc54b261455
 27SHA1 (patch-src_runtime_cgo_gcc__solaris__amd64.c) = 633d8dcc8a843e343ee2ab9edb7cfaf6f6c3865b
 28SHA1 (patch-src_runtime_cgo_setenv.c) = f3b56885fa54cabf78944fad75c21f04bea5cd88
 29SHA1 (patch-src_runtime_netpoll__solaris.c) = ae399518bb02d6b898734a52dfa7fe18f041e1ec
 30SHA1 (patch-src_runtime_os__solaris.c) = eec5b293fe4a72f58e4cd51cd23ea6e6fce714b6
 31SHA1 (patch-src_runtime_os__solaris.h) = c0a39aa6ab57eca7056178c87ebb00bb21236499
 32SHA1 (patch-src_runtime_sys__solaris__amd64.s) = 88f2e3fc43b0d6e4f17ef06d3f4f27cfed3103c6
 33SHA1 (patch-src_runtime_thunk__solaris__amd64.s) = 2835cdc171ae3209c61ef804fbfbf22cdf68bf43

File Added: pkgsrc/lang/go/patches/Attic/patch-doc_progs_run
$NetBSD: patch-doc_progs_run,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- doc/progs/run.orig	2014-12-11 01:18:10.000000000 +0000
+++ doc/progs/run
@@ -50,6 +50,10 @@ fi
 if [ "$goos" == "openbsd" ]; then
 	c_go_cgo="cgo1 cgo2"
 fi
+# cgo3 and cgo4 don't run on illumos, since cgo cannot handle stdout correctly
+if [ "$goos" == "solaris" ]; then
+	c_go_cgo="cgo1 cgo2"
+fi
 if [ "$CGO_ENABLED" != 1 ]; then
 	c_go_cgo=""
 fi

File Added: pkgsrc/lang/go/patches/Attic/patch-misc_cgo_test_cthread__unix.c
$NetBSD: patch-misc_cgo_test_cthread__unix.c,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- misc/cgo/test/cthread_unix.c.orig	2014-12-11 01:18:10.000000000 +0000
+++ misc/cgo/test/cthread_unix.c
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux netbsd openbsd
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
 
 #include <pthread.h>
 #include "_cgo_export.h"

File Added: pkgsrc/lang/go/patches/Attic/patch-misc_cgo_testso_cgoso.go
$NetBSD: patch-misc_cgo_testso_cgoso.go,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- misc/cgo/testso/cgoso.go.orig	2014-12-11 01:18:10.000000000 +0000
+++ misc/cgo/testso/cgoso.go
@@ -14,6 +14,7 @@ package cgosotest
 #cgo netbsd LDFLAGS: -L. libcgosotest.so
 #cgo darwin LDFLAGS: -L. libcgosotest.dylib
 #cgo windows LDFLAGS: -L. libcgosotest.dll
+#cgo solaris LDFLAGS: -L. -lcgosotest
 
 void init(void);
 void sofunc(void);

File Added: pkgsrc/lang/go/patches/Attic/patch-misc_cgo_testso_cgoso__unix.go
$NetBSD: patch-misc_cgo_testso_cgoso__unix.go,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- misc/cgo/testso/cgoso_unix.go.orig	2014-12-11 01:18:10.000000000 +0000
+++ misc/cgo/testso/cgoso_unix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build dragonfly freebsd linux netbsd
+// +build dragonfly freebsd linux netbsd solaris
 
 package cgosotest
 

File Added: pkgsrc/lang/go/patches/Attic/patch-src_cmd_5l_asm.c
$NetBSD: patch-src_cmd_5l_asm.c,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/cmd/5l/asm.c.orig	2014-12-11 01:18:10.000000000 +0000
+++ src/cmd/5l/asm.c
@@ -502,27 +502,8 @@ adddynsym(Link *ctxt, LSym *s)
 		adduint8(ctxt, d, t);
 		adduint8(ctxt, d, 0);
 
-		/* shndx */
-		if(s->type == SDYNIMPORT)
-			adduint16(ctxt, d, SHN_UNDEF);
-		else {
-			switch(s->type) {
-			default:
-			case STEXT:
-				t = 11;
-				break;
-			case SRODATA:
-				t = 12;
-				break;
-			case SDATA:
-				t = 13;
-				break;
-			case SBSS:
-				t = 14;
-				break;
-			}
-			adduint16(ctxt, d, t);
-		}
+		/* shndx; see dodynsym(). */
+		adduint16(ctxt, d, SHN_UNDEF);
 	} else {
 		diag("adddynsym: unsupported binary format");
 	}

File Added: pkgsrc/lang/go/patches/Attic/patch-src_cmd_6l_asm.c
$NetBSD: patch-src_cmd_6l_asm.c,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/cmd/6l/asm.c.orig	2014-12-11 01:18:10.000000000 +0000
+++ src/cmd/6l/asm.c
@@ -209,12 +209,23 @@ adddynrel(LSym *s, Reloc *r)
 	
 	case R_ADDR:
 		if(s->type == STEXT && iself) {
-			// The code is asking for the address of an external
-			// function.  We provide it with the address of the
-			// correspondent GOT symbol.
-			addgotsym(targ);
-			r->sym = linklookup(ctxt, ".got", 0);
-			r->add += targ->got;
+			/*
+			 * On SunOS, all external references are dynamic.
+			 * Emit a PLT relocation at this site.
+			 */
+			if (HEADTYPE == Hsolaris) {
+				addpltsym(targ);
+				r->sym = linklookup(ctxt, ".plt", 0);
+				r->add = targ->plt;
+			} else {
+				// The code is asking for the address of an
+				// external function.  We provide it with the
+				// address of the correspondent GOT symbol.
+				addgotsym(targ);
+				r->sym = linklookup(ctxt, ".got", 0);
+				r->add += targ->got;
+			}
+
 			return;
 		}
 		if(s->type != SDATA)
@@ -539,28 +550,9 @@ adddynsym(Link *ctxt, LSym *s)
 	
 		/* reserved */
 		adduint8(ctxt, d, 0);
-	
-		/* section where symbol is defined */
-		if(s->type == SDYNIMPORT)
-			adduint16(ctxt, d, SHN_UNDEF);
-		else {
-			switch(s->type) {
-			default:
-			case STEXT:
-				t = 11;
-				break;
-			case SRODATA:
-				t = 12;
-				break;
-			case SDATA:
-				t = 13;
-				break;
-			case SBSS:
-				t = 14;
-				break;
-			}
-			adduint16(ctxt, d, t);
-		}
+
+		/* section where symbol is defined; see dodynsym(). */
+		adduint16(ctxt, d, SHN_UNDEF);
 	
 		/* value */
 		if(s->type == SDYNIMPORT)

File Added: pkgsrc/lang/go/patches/Attic/patch-src_cmd_8l_asm.c
$NetBSD: patch-src_cmd_8l_asm.c,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/cmd/8l/asm.c.orig	2014-12-11 01:18:10.000000000 +0000
+++ src/cmd/8l/asm.c
@@ -508,27 +508,8 @@ adddynsym(Link *ctxt, LSym *s)
 		adduint8(ctxt, d, t);
 		adduint8(ctxt, d, 0);
 	
-		/* shndx */
-		if(s->type == SDYNIMPORT)
-			adduint16(ctxt, d, SHN_UNDEF);
-		else {
-			switch(s->type) {
-			default:
-			case STEXT:
-				t = 11;
-				break;
-			case SRODATA:
-				t = 12;
-				break;
-			case SDATA:
-				t = 13;
-				break;
-			case SBSS:
-				t = 14;
-				break;
-			}
-			adduint16(ctxt, d, t);
-		}
+		/* shndx; see dodynsym(). */
+		adduint16(ctxt, d, SHN_UNDEF);
 	} else if(HEADTYPE == Hdarwin) {
 		diag("adddynsym: missed symbol %s (%s)", s->name, s->extname);
 	} else if(HEADTYPE == Hwindows) {

File Added: pkgsrc/lang/go/patches/Attic/patch-src_cmd_ld_data.c
$NetBSD: patch-src_cmd_ld_data.c,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/cmd/ld/data.c.orig	2014-12-11 01:18:12.000000000 +0000
+++ src/cmd/ld/data.c
@@ -965,6 +965,46 @@ dodata(void)
 	datap = listsort(datap, datcmp, offsetof(LSym, next));
 
 	/*
+	 * The SunOS rtld expects the .rel/.rela and .rel.plt/.rela.plt
+	 * sections to be contiguous.  More properly, it expects that the
+	 * region starting from the lower of DT_RELA and DT_PLTREL and
+	 * continuing for DT_RELASZ bytes contains at least the set of non-PLT
+	 * relocation entries.  To ensure this, we put .rel[a].plt after .rel[a].
+	 * This is actually required by the ELF gABI on all ELF platforms.
+	 */
+	if (ctxt->headtype == Hsolaris) {
+		for (l = &datap; (s = *l) != nil; ) {
+			if (strcmp(s->name, ".rel.plt") == 0 ||
+			    strcmp(s->name, ".rela.plt") == 0) {
+				*l = s->next;
+				s->next = nil;
+				last = s;
+				break;
+			}
+			l = &s->next;
+		}
+
+		if (s != nil) {
+			for (s = datap; s != nil; s = s->next) {
+				if (strcmp(s->name, ".rel") == 0 ||
+				    strcmp(s->name, ".rela") == 0) {
+					last->next = s->next;
+					s->next = last;
+					break;
+				}
+			}
+			/*
+			 * .rel[a].plt without .rel[a].  Should never occur
+			 * but just in case, put it back where we found it.
+			 */
+			if (s == nil) {
+				last->next = (*l)->next;
+				(*l)->next = last;
+			}
+		}
+	}
+
+	/*
 	 * allocate sections.  list is sorted by type,
 	 * so we can just walk it for each piece we want to emit.
 	 * segdata is processed before segtext, because we need
@@ -1239,6 +1279,85 @@ dodata(void)
 		sect->extnum = n++;
 }
 
+/*
+ * Fix up the section numbers in .dynsym if present.  We could not write these
+ * shndx entries until we know all present sections and have sorted them.
+ *
+ * Each dynsym entry is actually an ElfXX_Sym, and we're going to replace the
+ * st_shndx field.  For 32-bit targets, that's at offset 0xe; for 64-bit, it's
+ * at offset 0x6.  Anything we don't expect, we ignore and leave unchanged.
+ */
+void
+dodynsym(void)
+{
+	LSym *ds;
+	LSym *ss;
+	LSym *s;
+	vlong off;
+	size_t entsz;
+	uint16 ent;
+	char *sectname = nil;
+
+	if (!iself)
+		return;
+
+	ds = linklookup(ctxt, ".dynsym", 0);
+
+	if (ds == nil)
+		return;
+
+	if (thechar == '6')
+		entsz = ELF64SYMSIZE;
+	else
+		entsz = ELF32SYMSIZE;
+
+	for(s = ctxt->allsym; s != nil; s = s->allsym) {
+		if (s->dynid <= 0 || s->type == SDYNIMPORT)
+			continue;
+
+		if (s->sect != nil) {
+			ent = s->sect->extnum;
+		} else {
+			switch (s->type) {
+			case STEXT:
+			default:
+				sectname = ".text";
+				break;
+			case SRODATA:
+				sectname = ".rodata";
+				break;
+			case SDATA:
+				sectname = ".data";
+				break;
+			case SBSS:
+				sectname = ".bss";
+				break;
+			}
+
+			ss = linklookup(ctxt, sectname, 0);
+			if (ss == nil || ss->sect == nil) {
+				diag("dodynsym: symbol %s in nonexistent %s",
+				    s->extname != nil ? s->extname : "<none>",
+				    sectname);
+				continue;
+			}
+
+			ent = ss->sect->extnum;
+		}
+
+		if (ent == 0) {
+			diag("dodynsym: symbol %s in section 0; ignored");
+			continue;
+		}
+
+		off = s->dynid * entsz +
+		    ((thechar == '6') ? offsetof(Elf64_Sym, shndx) :
+		    offsetof(Elf32_Sym, shndx));
+
+		(void) setuint16(ctxt, ds, off, ent);
+	}
+}
+
 // assign addresses to text
 void
 textaddress(void)

File Added: pkgsrc/lang/go/patches/Attic/patch-src_cmd_ld_doc.go
$NetBSD: patch-src_cmd_ld_doc.go,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/cmd/ld/doc.go.orig	2014-12-11 01:18:12.000000000 +0000
+++ src/cmd/ld/doc.go
@@ -30,7 +30,7 @@ Options new in this version:
 		Elide the dynamic linking header.  With this option, the binary
 		is statically linked and does not refer to a dynamic linker.  Without this option
 		(the default), the binary's contents are identical but it is loaded with a dynamic
-		linker. This flag cannot be used when $GOOS is windows.
+		linker. This flag cannot be used when $GOOS is windows or solaris
 	-H darwin     (only in 6l/8l)
 		Write Apple Mach-O binaries (default when $GOOS is darwin)
 	-H dragonfly  (only in 6l/8l)

File Added: pkgsrc/lang/go/patches/Attic/patch-src_cmd_ld_lib.h
$NetBSD: patch-src_cmd_ld_lib.h,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/cmd/ld/lib.h.orig	2014-12-11 01:18:12.000000000 +0000
+++ src/cmd/ld/lib.h
@@ -216,6 +216,7 @@ char*	decodetype_structfieldname(LSym *s
 vlong	decodetype_structfieldoffs(LSym *s, int i);
 LSym*	decodetype_structfieldtype(LSym *s, int i);
 void	dodata(void);
+void	dodynsym(void);
 void	dostkcheck(void);
 void	dostkoff(void);
 void	dosymtype(void);

File Added: pkgsrc/lang/go/patches/Attic/patch-src_cmd_ld_pobj.c
$NetBSD: patch-src_cmd_ld_pobj.c,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/cmd/ld/pobj.c.orig	2014-12-11 01:18:10.000000000 +0000
+++ src/cmd/ld/pobj.c
@@ -151,6 +151,12 @@ main(int argc, char *argv[])
 	if(headstring == nil)
 		headstring = headstr(HEADTYPE);
 
+	if (HEADTYPE == Hsolaris && debug['d'] != 0) {
+		fprint(2, "%cl: -d is not supported with this target\n",
+		    thechar);
+		exits("usage");
+	}
+
 	archinit();
 	ctxt->debugfloat = debug['F'];
 
@@ -188,6 +194,7 @@ main(int argc, char *argv[])
 	pclntab();
 	symtab();
 	dodata();
+	dodynsym();
 	address();
 	doweak();
 	reloc();

File Added: pkgsrc/lang/go/patches/Attic/patch-src_go_build_build.go
$NetBSD: patch-src_go_build_build.go,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/go/build/build.go.orig	2014-12-11 01:18:12.000000000 +0000
+++ src/go/build/build.go
@@ -277,6 +277,7 @@ var cgoEnabled = map[string]bool{
 	"openbsd/amd64":   true,
 	"windows/386":     true,
 	"windows/amd64":   true,
+	"solaris/amd64":   true,
 }
 
 func defaultContext() Context {

File Added: pkgsrc/lang/go/patches/Attic/patch-src_net_cgo__bsd.go
$NetBSD: patch-src_net_cgo__bsd.go,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/net/cgo_bsd.go.orig	2014-12-11 01:18:10.000000000 +0000
+++ src/net/cgo_bsd.go
@@ -3,7 +3,7 @@
 // license that can be found in the LICENSE file.
 
 // +build !netgo
-// +build darwin dragonfly freebsd solaris
+// +build darwin dragonfly freebsd
 
 package net
 

File Added: pkgsrc/lang/go/patches/Attic/patch-src_net_cgo__stub.go
$NetBSD: patch-src_net_cgo__stub.go,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/net/cgo_stub.go.orig	2014-12-11 01:18:10.000000000 +0000
+++ src/net/cgo_stub.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build !cgo netgo
+// +build !cgo netgo solaris
 
 // Stub cgo routines for systems that do not use cgo to do network lookups.
 

File Added: pkgsrc/lang/go/patches/Attic/patch-src_net_cgo__unix.go
$NetBSD: patch-src_net_cgo__unix.go,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/net/cgo_unix.go.orig	2014-12-11 01:18:10.000000000 +0000
+++ src/net/cgo_unix.go
@@ -3,7 +3,7 @@
 // license that can be found in the LICENSE file.
 
 // +build !netgo
-// +build darwin dragonfly freebsd linux netbsd openbsd
+// +build darwin dragonfly freebsd linux netbsd openbsd !solaris
 
 package net
 

File Added: pkgsrc/lang/go/patches/Attic/patch-src_os_user_lookup__unix.go
$NetBSD: patch-src_os_user_lookup__unix.go,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/os/user/lookup_unix.go.orig	2014-12-11 01:18:10.000000000 +0000
+++ src/os/user/lookup_unix.go
@@ -17,6 +17,7 @@ import (
 )
 
 /*
+#cgo solaris CFLAGS: -D_POSIX_PTHREAD_SEMANTICS
 #include <unistd.h>
 #include <sys/types.h>
 #include <pwd.h>

File Added: pkgsrc/lang/go/patches/Attic/patch-src_runtime_cgo_cgo.go
$NetBSD: patch-src_runtime_cgo_cgo.go,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/runtime/cgo/cgo.go.orig	2014-12-11 01:18:10.000000000 +0000
+++ src/runtime/cgo/cgo.go
@@ -21,6 +21,7 @@ package cgo
 #cgo windows LDFLAGS: -lm -mthreads
 
 #cgo CFLAGS: -Wall -Werror
+#cgo solaris CFLAGS: -D_POSIX_PTHREAD_SEMANTICS
 
 */
 import "C"

File Added: pkgsrc/lang/go/patches/Attic/patch-src_runtime_cgo_gcc__setenv.c
$NetBSD: patch-src_runtime_cgo_gcc__setenv.c,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/runtime/cgo/gcc_setenv.c.orig	2014-12-11 01:18:10.000000000 +0000
+++ src/runtime/cgo/gcc_setenv.c
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux netbsd openbsd
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
 
 #include "libcgo.h"
 

File Added: pkgsrc/lang/go/patches/Attic/patch-src_runtime_cgo_gcc__solaris__amd64.c
$NetBSD: patch-src_runtime_cgo_gcc__solaris__amd64.c,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- /dev/null
+++ src/runtime/cgo/gcc_solaris_amd64.c
@@ -0,0 +1,70 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include <pthread.h>
+#include <string.h>
+#include <signal.h>
+#include "libcgo.h"
+
+static void* threadentry(void*);
+static void (*setg_gcc)(void*);
+
+void
+x_cgo_init(G *g, void (*setg)(void*))
+{
+	pthread_attr_t attr;
+	size_t size;
+
+	setg_gcc = setg;
+	pthread_attr_init(&attr);
+	if (pthread_attr_getstack(&attr, (void **)&g->stacklo, &size) != 0)
+		perror("runtime/cgo: pthread_attr_getstack failed");
+	g->stackhi = (uintptr_t)g->stacklo + 8192;
+	pthread_attr_destroy(&attr);
+}
+
+void
+_cgo_sys_thread_start(ThreadStart *ts)
+{
+	pthread_attr_t attr;
+	sigset_t ign, oset;
+	pthread_t p;
+	size_t size;
+	int err;
+
+	sigfillset(&ign);
+	pthread_sigmask(SIG_SETMASK, &ign, &oset);
+
+	pthread_attr_init(&attr);
+
+	if (pthread_attr_getstack(&attr, (void **)&ts->g->stacklo, &size) != 0)
+		perror("runtime/cgo: pthread_attr_getstack failed");
+	ts->g->stackhi = (uintptr_t)ts->g->stacklo + 8192;
+	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+	err = pthread_create(&p, &attr, threadentry, ts);
+
+	pthread_sigmask(SIG_SETMASK, &oset, nil);
+
+	if (err != 0) {
+		fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err));
+		abort();
+	}
+}
+
+static void*
+threadentry(void *v)
+{
+	ThreadStart ts;
+
+	ts = *(ThreadStart*)v;
+	free(v);
+
+	/*
+	 * Set specific keys.
+	 */
+	setg_gcc((void*)ts.g);
+
+	crosscall_amd64(ts.fn);
+	return nil;
+}

File Added: pkgsrc/lang/go/patches/Attic/patch-src_runtime_cgo_setenv.c
$NetBSD: patch-src_runtime_cgo_setenv.c,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/runtime/cgo/setenv.c.orig	2014-12-11 01:18:12.000000000 +0000
+++ src/runtime/cgo/setenv.c
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux netbsd openbsd
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
 
 #pragma cgo_import_static x_cgo_setenv
 #pragma cgo_import_static x_cgo_unsetenv

File Added: pkgsrc/lang/go/patches/Attic/patch-src_runtime_netpoll__solaris.c
$NetBSD: patch-src_runtime_netpoll__solaris.c,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/runtime/netpoll_solaris.c.orig	2014-12-11 01:18:12.000000000 +0000
+++ src/runtime/netpoll_solaris.c
@@ -73,11 +73,14 @@
 #pragma dynimport libc·port_associate port_associate "libc.so"
 #pragma dynimport libc·port_dissociate port_dissociate "libc.so"
 #pragma dynimport libc·port_getn port_getn "libc.so"
-extern uintptr libc·fcntl;
-extern uintptr libc·port_create;
-extern uintptr libc·port_associate;
-extern uintptr libc·port_dissociate;
-extern uintptr libc·port_getn;
+
+typedef uintptr (extf)();
+
+extern extf libc·fcntl;
+extern extf libc·port_create;
+extern extf libc·port_associate;
+extern extf libc·port_dissociate;
+extern extf libc·port_getn;
 
 #define errno (*g->m->perrno)
 

File Added: pkgsrc/lang/go/patches/Attic/patch-src_runtime_os__solaris.c
$NetBSD: patch-src_runtime_os__solaris.c,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/runtime/os_solaris.c.orig	2014-12-11 01:18:12.000000000 +0000
+++ src/runtime/os_solaris.c
@@ -46,38 +46,40 @@
 #pragma dynimport libc·usleep usleep "libc.so"
 #pragma dynimport libc·write write "libc.so"
 
-extern uintptr libc·___errno;
-extern uintptr libc·clock_gettime;
-extern uintptr libc·close;
-extern uintptr libc·exit;
-extern uintptr libc·fstat;
-extern uintptr libc·getcontext;
-extern uintptr libc·getrlimit;
-extern uintptr libc·malloc;
-extern uintptr libc·mmap;
-extern uintptr libc·munmap;
-extern uintptr libc·open;
-extern uintptr libc·pthread_attr_destroy;
-extern uintptr libc·pthread_attr_getstack;
-extern uintptr libc·pthread_attr_init;
-extern uintptr libc·pthread_attr_setdetachstate;
-extern uintptr libc·pthread_attr_setstack;
-extern uintptr libc·pthread_create;
-extern uintptr libc·raise;
-extern uintptr libc·read;
-extern uintptr libc·sched_yield;
-extern uintptr libc·select;
-extern uintptr libc·sem_init;
-extern uintptr libc·sem_post;
-extern uintptr libc·sem_reltimedwait_np;
-extern uintptr libc·sem_wait;
-extern uintptr libc·setitimer;
-extern uintptr libc·sigaction;
-extern uintptr libc·sigaltstack;
-extern uintptr libc·sigprocmask;
-extern uintptr libc·sysconf;
-extern uintptr libc·usleep;
-extern uintptr libc·write;
+typedef uintptr (extf)();
+
+extern extf libc·___errno;
+extern extf libc·clock_gettime;
+extern extf libc·close;
+extern extf libc·exit;
+extern extf libc·fstat;
+extern extf libc·getcontext;
+extern extf libc·getrlimit;
+extern extf libc·malloc;
+extern extf libc·mmap;
+extern extf libc·munmap;
+extern extf libc·open;
+extern extf libc·pthread_attr_destroy;
+extern extf libc·pthread_attr_getstack;
+extern extf libc·pthread_attr_init;
+extern extf libc·pthread_attr_setdetachstate;
+extern extf libc·pthread_attr_setstack;
+extern extf libc·pthread_create;
+extern extf libc·raise;
+extern extf libc·read;
+extern extf libc·sched_yield;
+extern extf libc·select;
+extern extf libc·sem_init;
+extern extf libc·sem_post;
+extern extf libc·sem_reltimedwait_np;
+extern extf libc·sem_wait;
+extern extf libc·setitimer;
+extern extf libc·sigaction;
+extern extf libc·sigaltstack;
+extern extf libc·sigprocmask;
+extern extf libc·sysconf;
+extern extf libc·usleep;
+extern extf libc·write;
 
 void	runtime·getcontext(Ucontext *context);
 int32	runtime·pthread_attr_destroy(PthreadAttr* attr);
@@ -396,12 +398,13 @@ runtime·munmap(byte* addr, uintptr len)
 	runtime·sysvicall2(libc·munmap, (uintptr)addr, (uintptr)len);
 }
 
-extern int64 runtime·nanotime1(void);
+extern uintptr runtime·nanotime1(void);
+
 #pragma textflag NOSPLIT
 int64
 runtime·nanotime(void)
 {
-	return runtime·sysvicall0((uintptr)runtime·nanotime1);
+	return runtime·sysvicall0(runtime·nanotime1);
 }
 
 #pragma textflag NOSPLIT

File Added: pkgsrc/lang/go/patches/Attic/patch-src_runtime_os__solaris.h
$NetBSD: patch-src_runtime_os__solaris.h,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/runtime/os_solaris.h.orig	2014-12-11 01:18:12.000000000 +0000
+++ src/runtime/os_solaris.h
@@ -43,13 +43,13 @@ int32   runtime·getrlimit(int32, Rlimit
 
 // Call an external library function described by {fn, a0, ..., an}, with
 // SysV conventions, switching to os stack during the call, if necessary.
-uintptr	runtime·sysvicall0(uintptr fn);
-uintptr	runtime·sysvicall1(uintptr fn, uintptr a1);
-uintptr	runtime·sysvicall2(uintptr fn, uintptr a1, uintptr a2);
-uintptr	runtime·sysvicall3(uintptr fn, uintptr a1, uintptr a2, uintptr a3);
-uintptr	runtime·sysvicall4(uintptr fn, uintptr a1, uintptr a2, uintptr a3, uintptr a4);
-uintptr	runtime·sysvicall5(uintptr fn, uintptr a1, uintptr a2, uintptr a3, uintptr a4, uintptr a5);
-uintptr	runtime·sysvicall6(uintptr fn, uintptr a1, uintptr a2, uintptr a3, uintptr a4, uintptr a5, uintptr a6);
+uintptr	runtime·sysvicall0(uintptr (*fn)());
+uintptr	runtime·sysvicall1(uintptr (*fn)(), uintptr a1);
+uintptr	runtime·sysvicall2(uintptr (*fn)(), uintptr a1, uintptr a2);
+uintptr	runtime·sysvicall3(uintptr (*fn)(), uintptr a1, uintptr a2, uintptr a3);
+uintptr	runtime·sysvicall4(uintptr (*fn)(), uintptr a1, uintptr a2, uintptr a3, uintptr a4);
+uintptr	runtime·sysvicall5(uintptr (*fn)(), uintptr a1, uintptr a2, uintptr a3, uintptr a4, uintptr a5);
+uintptr	runtime·sysvicall6(uintptr (*fn)(), uintptr a1, uintptr a2, uintptr a3, uintptr a4, uintptr a5, uintptr a6);
 void	runtime·asmsysvicall6(void *c);
 
 void	runtime·miniterrno(void *fn);

File Added: pkgsrc/lang/go/patches/Attic/patch-src_runtime_sys__solaris__amd64.s
$NetBSD: patch-src_runtime_sys__solaris__amd64.s,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/runtime/sys_solaris_amd64.s.orig	2014-12-11 01:18:12.000000000 +0000
+++ src/runtime/sys_solaris_amd64.s
@@ -40,7 +40,7 @@ TEXT runtime·nanotime1(SB),NOSPLIT,$0
 	SUBQ	$64, SP	// 16 bytes will do, but who knows in the future?
 	MOVQ	$3, DI	// CLOCK_REALTIME from <sys/time_impl.h>
 	MOVQ	SP, SI
-	MOVQ	libc·clock_gettime(SB), AX
+	LEAQ	libc·clock_gettime(SB), AX
 	CALL	AX
 	MOVQ	(SP), AX	// tv_sec from struct timespec
 	IMULQ	$1000000000, AX	// multiply into nanoseconds
@@ -53,7 +53,7 @@ TEXT runtime·nanotime1(SB),NOSPLIT,$0
 TEXT runtime·pipe1(SB),NOSPLIT,$0
 	SUBQ	$16, SP // 8 bytes will do, but stack has to be 16-byte alligned
 	MOVQ	SP, DI
-	MOVQ	libc·pipe(SB), AX
+	LEAQ	libc·pipe(SB), AX
 	CALL	AX
 	MOVL	0(SP), AX
 	MOVL	4(SP), DX
@@ -320,13 +320,13 @@ usleep1_noswitch:
 
 // Runs on OS stack. duration (in µs units) is in DI.
 TEXT runtime·usleep2(SB),NOSPLIT,$0
-	MOVQ	libc·usleep(SB), AX
+	LEAQ	libc·usleep(SB), AX
 	CALL	AX
 	RET
 
 // Runs on OS stack, called from runtime·osyield.
 TEXT runtime·osyield1(SB),NOSPLIT,$0
-	MOVQ	libc·sched_yield(SB), AX
+	LEAQ	libc·sched_yield(SB), AX
 	CALL	AX
 	RET
 

File Added: pkgsrc/lang/go/patches/Attic/patch-src_runtime_thunk__solaris__amd64.s
$NetBSD: patch-src_runtime_thunk__solaris__amd64.s,v 1.1 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/runtime/thunk_solaris_amd64.s.orig	2014-12-11 01:18:12.000000000 +0000
+++ src/runtime/thunk_solaris_amd64.s
@@ -8,81 +8,81 @@
 #include "textflag.h"
 
 TEXT runtime·libc_chdir(SB),NOSPLIT,$0
-	MOVQ	libc·chdir(SB), AX
+	LEAQ	libc·chdir(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_chroot(SB),NOSPLIT,$0
-	MOVQ	libc·chroot(SB), AX
+	LEAQ	libc·chroot(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_close(SB),NOSPLIT,$0
-	MOVQ	libc·close(SB), AX
+	LEAQ	libc·close(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_dlopen(SB),NOSPLIT,$0
-	MOVQ	libc·dlopen(SB), AX
+	LEAQ	libc·dlopen(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_dlclose(SB),NOSPLIT,$0
-	MOVQ	libc·dlclose(SB), AX
+	LEAQ	libc·dlclose(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_dlsym(SB),NOSPLIT,$0
-	MOVQ	libc·dlsym(SB), AX
+	LEAQ	libc·dlsym(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_execve(SB),NOSPLIT,$0
-	MOVQ	libc·execve(SB), AX
+	LEAQ	libc·execve(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_exit(SB),NOSPLIT,$0
-	MOVQ	libc·exit(SB), AX
+	LEAQ	libc·exit(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_fcntl(SB),NOSPLIT,$0
-	MOVQ	libc·fcntl(SB), AX
+	LEAQ	libc·fcntl(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_forkx(SB),NOSPLIT,$0
-	MOVQ	libc·forkx(SB), AX
+	LEAQ	libc·forkx(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_gethostname(SB),NOSPLIT,$0
-	MOVQ	libc·gethostname(SB), AX
+	LEAQ	libc·gethostname(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_ioctl(SB),NOSPLIT,$0
-	MOVQ	libc·ioctl(SB), AX
+	LEAQ	libc·ioctl(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_setgid(SB),NOSPLIT,$0
-	MOVQ	libc·setgid(SB), AX
+	LEAQ	libc·setgid(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_setgroups(SB),NOSPLIT,$0
-	MOVQ	libc·setgroups(SB), AX
+	LEAQ	libc·setgroups(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_setsid(SB),NOSPLIT,$0
-	MOVQ	libc·setsid(SB), AX
+	LEAQ	libc·setsid(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_setuid(SB),NOSPLIT,$0
-	MOVQ	libc·setuid(SB), AX
+	LEAQ	libc·setuid(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_setpgid(SB),NOSPLIT,$0
-	MOVQ	libc·setpgid(SB), AX
+	LEAQ	libc·setpgid(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_syscall(SB),NOSPLIT,$0
-	MOVQ	libc·syscall(SB), AX
+	LEAQ	libc·syscall(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_wait4(SB),NOSPLIT,$0
-	MOVQ	libc·wait4(SB), AX
+	LEAQ	libc·wait4(SB), AX
 	JMP	AX
 
 TEXT runtime·libc_write(SB),NOSPLIT,$0
-	MOVQ	libc·write(SB), AX
+	LEAQ	libc·write(SB), AX
 	JMP	AX

File Added: pkgsrc/lang/go/patches/Attic/patch-src_cmd_go_build.go
$NetBSD: patch-src_cmd_go_build.go,v 1.3 2015/03/10 13:11:36 jperkin Exp $

Support cgo on illumos.

--- src/cmd/go/build.go.orig	2014-12-11 01:18:12.000000000 +0000
+++ src/cmd/go/build.go
@@ -2330,6 +2330,10 @@ func (b *builder) cgo(p *Package, cgoExe
 	if pie { // we need to use -pie for Linux/ARM to get accurate imported sym
 		cgoLDFLAGS = append(cgoLDFLAGS, "-pie")
 	}
+	lgcc_s := goos == "solaris"
+	if lgcc_s {
+		cgoLDFLAGS = append(cgoLDFLAGS, "-lgcc_s");
+	}
 	if err := b.gccld(p, dynobj, cgoLDFLAGS, linkobj); err != nil {
 		return nil, nil, err
 	}