summaryrefslogtreecommitdiff
path: root/lang/go
diff options
context:
space:
mode:
authorjperkin <jperkin>2015-03-10 13:11:36 +0000
committerjperkin <jperkin>2015-03-10 13:11:36 +0000
commit46d209dc2723515e4b40933505c08b8ff234e908 (patch)
treeb7f0682d30ed7bea8cd7fe799286e839c62b24cc /lang/go
parent441b3c8a8a44ca1208fd548888662828589fd84a (diff)
downloadpkgsrc-46d209dc2723515e4b40933505c08b8ff234e908.tar.gz
Implement cgo support for illumos. Patches by Keith Wesolowski at Joyent.
Bump PKGREVISION.
Diffstat (limited to 'lang/go')
-rw-r--r--lang/go/Makefile13
-rw-r--r--lang/go/PLIST5
-rw-r--r--lang/go/distinfo28
-rw-r--r--lang/go/patches/patch-doc_progs_run17
-rw-r--r--lang/go/patches/patch-misc_cgo_test_cthread__unix.c15
-rw-r--r--lang/go/patches/patch-misc_cgo_testso_cgoso.go14
-rw-r--r--lang/go/patches/patch-misc_cgo_testso_cgoso__unix.go15
-rw-r--r--lang/go/patches/patch-src_cmd_5l_asm.c36
-rw-r--r--lang/go/patches/patch-src_cmd_6l_asm.c68
-rw-r--r--lang/go/patches/patch-src_cmd_8l_asm.c36
-rw-r--r--lang/go/patches/patch-src_cmd_go_build.go17
-rw-r--r--lang/go/patches/patch-src_cmd_ld_data.c139
-rw-r--r--lang/go/patches/patch-src_cmd_ld_doc.go15
-rw-r--r--lang/go/patches/patch-src_cmd_ld_lib.h14
-rw-r--r--lang/go/patches/patch-src_cmd_ld_pobj.c27
-rw-r--r--lang/go/patches/patch-src_go_build_build.go14
-rw-r--r--lang/go/patches/patch-src_net_cgo__bsd.go15
-rw-r--r--lang/go/patches/patch-src_net_cgo__stub.go15
-rw-r--r--lang/go/patches/patch-src_net_cgo__unix.go15
-rw-r--r--lang/go/patches/patch-src_os_user_lookup__unix.go14
-rw-r--r--lang/go/patches/patch-src_runtime_cgo_cgo.go14
-rw-r--r--lang/go/patches/patch-src_runtime_cgo_gcc__setenv.c15
-rw-r--r--lang/go/patches/patch-src_runtime_cgo_gcc__solaris__amd64.c77
-rw-r--r--lang/go/patches/patch-src_runtime_cgo_setenv.c15
-rw-r--r--lang/go/patches/patch-src_runtime_netpoll__solaris.c26
-rw-r--r--lang/go/patches/patch-src_runtime_os__solaris.c95
-rw-r--r--lang/go/patches/patch-src_runtime_os__solaris.h27
-rw-r--r--lang/go/patches/patch-src_runtime_sys__solaris__amd64.s40
-rw-r--r--lang/go/patches/patch-src_runtime_thunk__solaris__amd64.s108
29 files changed, 936 insertions, 13 deletions
diff --git a/lang/go/Makefile b/lang/go/Makefile
index e4fcc2086e7..783455747e2 100644
--- a/lang/go/Makefile
+++ b/lang/go/Makefile
@@ -1,9 +1,10 @@
-# $NetBSD: Makefile,v 1.26 2015/02/22 13:28:30 tnn Exp $
+# $NetBSD: Makefile,v 1.27 2015/03/10 13:11:36 jperkin Exp $
.include "version.mk"
DISTNAME= go${GO_VERSION}.src
PKGNAME= go-${GO_VERSION}
+PKGREVISION= 1
CATEGORIES= lang
MASTER_SITES= https://storage.googleapis.com/golang/
PATCH_SITES= https://codereview.appspot.com/download/
@@ -19,14 +20,6 @@ USE_TOOLS+= bash:run perl:run pax
# uses ulimit -T
BUILD_DEPENDS+= bash>=4.2nb3:../../shells/bash
-PLIST_VARS+= cgo zsyscall
-
-.if ${OPSYS} == "SunOS"
-PLIST.zsyscall= yes
-.else
-PLIST.cgo= yes
-.endif
-
# cgo compiles under TMPDIR
TMPDIR?= /tmp
BUILDLINK_PASSTHRU_DIRS+= ${TMPDIR}
@@ -93,7 +86,7 @@ do-build:
do-install:
cd ${WRKSRC} && rm -rf .hgignore .hgtags pkg/obj
cd ${WRKDIR} && pax -rw go ${DESTDIR}${PREFIX}
- find ${DESTDIR}${PREFIX}/go/src -name \*.orig -exec rm {} \;
+ find ${DESTDIR}${PREFIX}/go -name \*.orig -exec rm {} \;
.for cmd in go gofmt
cd ${DESTDIR}${PREFIX}/bin && ln -sf ../go/bin/${cmd} ${cmd}
.endfor
diff --git a/lang/go/PLIST b/lang/go/PLIST
index 78723fe4033..15dedbcfa4a 100644
--- a/lang/go/PLIST
+++ b/lang/go/PLIST
@@ -1,4 +1,4 @@
-@comment $NetBSD: PLIST,v 1.17 2015/02/22 13:14:09 mspo Exp $
+@comment $NetBSD: PLIST,v 1.18 2015/03/10 13:11:36 jperkin Exp $
bin/go
bin/gofmt
go/AUTHORS
@@ -515,7 +515,7 @@ go/pkg/${GO_PLATFORM}/regexp.a
go/pkg/${GO_PLATFORM}/regexp/syntax.a
go/pkg/${GO_PLATFORM}/runtime.a
go/pkg/${GO_PLATFORM}/runtime.h
-${PLIST.cgo}go/pkg/${GO_PLATFORM}/runtime/cgo.a
+go/pkg/${GO_PLATFORM}/runtime/cgo.a
go/pkg/${GO_PLATFORM}/runtime/debug.a
go/pkg/${GO_PLATFORM}/runtime/pprof.a
go/pkg/${GO_PLATFORM}/runtime/race.a
@@ -2570,6 +2570,7 @@ go/src/runtime/cgo/gcc_netbsd_arm.c
go/src/runtime/cgo/gcc_openbsd_386.c
go/src/runtime/cgo/gcc_openbsd_amd64.c
go/src/runtime/cgo/gcc_setenv.c
+go/src/runtime/cgo/gcc_solaris_amd64.c
go/src/runtime/cgo/gcc_util.c
go/src/runtime/cgo/gcc_windows_386.c
go/src/runtime/cgo/gcc_windows_amd64.c
diff --git a/lang/go/distinfo b/lang/go/distinfo
index b28f0e7a61e..e99c065683f 100644
--- a/lang/go/distinfo
+++ b/lang/go/distinfo
@@ -1,7 +1,33 @@
-$NetBSD: distinfo,v 1.21 2015/02/22 13:29:01 tnn Exp $
+$NetBSD: distinfo,v 1.22 2015/03/10 13:11:36 jperkin Exp $
SHA1 (go1.4.2.src.tar.gz) = 460caac03379f746c473814a65223397e9c9a2f6
RMD160 (go1.4.2.src.tar.gz) = dea15b3b4c31554a47b40799f4b9a926ea760e70
Size (go1.4.2.src.tar.gz) = 10921896 bytes
+SHA1 (patch-doc_progs_run) = 5a29fe4f91defb2e20d192850601df7cbabdac7c
+SHA1 (patch-misc_cgo_test_cthread__unix.c) = a63f08f07713bd32e279315cca21235101ce9cd3
+SHA1 (patch-misc_cgo_testso_cgoso.go) = ef782a6f173c814656eac0df640aedaa1a923bbc
+SHA1 (patch-misc_cgo_testso_cgoso__unix.go) = 58e221e1ce123428a3fe6ecededf0590cbfb81ca
+SHA1 (patch-src_cmd_5l_asm.c) = fd78203b7c92b9bbd057077671d649bac2d121ee
+SHA1 (patch-src_cmd_6l_asm.c) = 1f244d7c760e738057b1649ed486206a6ec3812b
+SHA1 (patch-src_cmd_8l_asm.c) = e5233a3d9b08f2ef8d809756ef7d6fc4b03303b9
+SHA1 (patch-src_cmd_go_build.go) = f7705aa955241d3add353a144a676a58a0a1617e
SHA1 (patch-src_cmd_go_pkg.go) = e70441f3fdf312eb389e4dd5408c207a4d4b8350
+SHA1 (patch-src_cmd_ld_data.c) = 96181bac03333f7bc5293ab9ddbd68bb9174ed47
+SHA1 (patch-src_cmd_ld_doc.go) = 000447f5a5862358a85a7510dc92195494972e26
+SHA1 (patch-src_cmd_ld_lib.h) = e6aa8b9520e1b75f435e179e5ea4f0ef738621f4
+SHA1 (patch-src_cmd_ld_pobj.c) = eaf67d6bc4f9ba835893f9d8c2d36941ff84933d
SHA1 (patch-src_crypto_x509_root__unix.go) = c933f334da1c8de48a06d23abd12da01f73776e6
+SHA1 (patch-src_go_build_build.go) = b68bc557e7b48877889c63070e9cb9d8360f40f5
+SHA1 (patch-src_net_cgo__bsd.go) = 4678fccd6956300ce55343965334fc3881383bbc
+SHA1 (patch-src_net_cgo__stub.go) = cf373587745d68e556dadf3a61956b489b4f420a
+SHA1 (patch-src_net_cgo__unix.go) = cebe897ab624aaf52bebc50d12a045d6b4ea2bc6
+SHA1 (patch-src_os_user_lookup__unix.go) = 861cf9b2b64bc314b6ee8e11411245e214717515
+SHA1 (patch-src_runtime_cgo_cgo.go) = 9cc88b35d12e0d52e76495e04f7fce2b78af08d5
+SHA1 (patch-src_runtime_cgo_gcc__setenv.c) = c9614b76d71e84ad46b2ce785580fdc54b261455
+SHA1 (patch-src_runtime_cgo_gcc__solaris__amd64.c) = 633d8dcc8a843e343ee2ab9edb7cfaf6f6c3865b
+SHA1 (patch-src_runtime_cgo_setenv.c) = f3b56885fa54cabf78944fad75c21f04bea5cd88
+SHA1 (patch-src_runtime_netpoll__solaris.c) = ae399518bb02d6b898734a52dfa7fe18f041e1ec
+SHA1 (patch-src_runtime_os__solaris.c) = eec5b293fe4a72f58e4cd51cd23ea6e6fce714b6
+SHA1 (patch-src_runtime_os__solaris.h) = c0a39aa6ab57eca7056178c87ebb00bb21236499
+SHA1 (patch-src_runtime_sys__solaris__amd64.s) = 88f2e3fc43b0d6e4f17ef06d3f4f27cfed3103c6
+SHA1 (patch-src_runtime_thunk__solaris__amd64.s) = 2835cdc171ae3209c61ef804fbfbf22cdf68bf43
diff --git a/lang/go/patches/patch-doc_progs_run b/lang/go/patches/patch-doc_progs_run
new file mode 100644
index 00000000000..9380b3278e9
--- /dev/null
+++ b/lang/go/patches/patch-doc_progs_run
@@ -0,0 +1,17 @@
+$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
diff --git a/lang/go/patches/patch-misc_cgo_test_cthread__unix.c b/lang/go/patches/patch-misc_cgo_test_cthread__unix.c
new file mode 100644
index 00000000000..a568adaf2f0
--- /dev/null
+++ b/lang/go/patches/patch-misc_cgo_test_cthread__unix.c
@@ -0,0 +1,15 @@
+$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"
diff --git a/lang/go/patches/patch-misc_cgo_testso_cgoso.go b/lang/go/patches/patch-misc_cgo_testso_cgoso.go
new file mode 100644
index 00000000000..af8b604d8cd
--- /dev/null
+++ b/lang/go/patches/patch-misc_cgo_testso_cgoso.go
@@ -0,0 +1,14 @@
+$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);
diff --git a/lang/go/patches/patch-misc_cgo_testso_cgoso__unix.go b/lang/go/patches/patch-misc_cgo_testso_cgoso__unix.go
new file mode 100644
index 00000000000..ea2966d5a25
--- /dev/null
+++ b/lang/go/patches/patch-misc_cgo_testso_cgoso__unix.go
@@ -0,0 +1,15 @@
+$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
+
diff --git a/lang/go/patches/patch-src_cmd_5l_asm.c b/lang/go/patches/patch-src_cmd_5l_asm.c
new file mode 100644
index 00000000000..8952e3458a6
--- /dev/null
+++ b/lang/go/patches/patch-src_cmd_5l_asm.c
@@ -0,0 +1,36 @@
+$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");
+ }
diff --git a/lang/go/patches/patch-src_cmd_6l_asm.c b/lang/go/patches/patch-src_cmd_6l_asm.c
new file mode 100644
index 00000000000..8bbc274394f
--- /dev/null
+++ b/lang/go/patches/patch-src_cmd_6l_asm.c
@@ -0,0 +1,68 @@
+$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)
diff --git a/lang/go/patches/patch-src_cmd_8l_asm.c b/lang/go/patches/patch-src_cmd_8l_asm.c
new file mode 100644
index 00000000000..12bb32dec01
--- /dev/null
+++ b/lang/go/patches/patch-src_cmd_8l_asm.c
@@ -0,0 +1,36 @@
+$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) {
diff --git a/lang/go/patches/patch-src_cmd_go_build.go b/lang/go/patches/patch-src_cmd_go_build.go
new file mode 100644
index 00000000000..c492c2d77af
--- /dev/null
+++ b/lang/go/patches/patch-src_cmd_go_build.go
@@ -0,0 +1,17 @@
+$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
+ }
diff --git a/lang/go/patches/patch-src_cmd_ld_data.c b/lang/go/patches/patch-src_cmd_ld_data.c
new file mode 100644
index 00000000000..70ef8558cdd
--- /dev/null
+++ b/lang/go/patches/patch-src_cmd_ld_data.c
@@ -0,0 +1,139 @@
+$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)
diff --git a/lang/go/patches/patch-src_cmd_ld_doc.go b/lang/go/patches/patch-src_cmd_ld_doc.go
new file mode 100644
index 00000000000..49866d4ee65
--- /dev/null
+++ b/lang/go/patches/patch-src_cmd_ld_doc.go
@@ -0,0 +1,15 @@
+$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)
diff --git a/lang/go/patches/patch-src_cmd_ld_lib.h b/lang/go/patches/patch-src_cmd_ld_lib.h
new file mode 100644
index 00000000000..cac0d5e7f02
--- /dev/null
+++ b/lang/go/patches/patch-src_cmd_ld_lib.h
@@ -0,0 +1,14 @@
+$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);
diff --git a/lang/go/patches/patch-src_cmd_ld_pobj.c b/lang/go/patches/patch-src_cmd_ld_pobj.c
new file mode 100644
index 00000000000..f0bd65f3622
--- /dev/null
+++ b/lang/go/patches/patch-src_cmd_ld_pobj.c
@@ -0,0 +1,27 @@
+$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();
diff --git a/lang/go/patches/patch-src_go_build_build.go b/lang/go/patches/patch-src_go_build_build.go
new file mode 100644
index 00000000000..8c97b52cfc8
--- /dev/null
+++ b/lang/go/patches/patch-src_go_build_build.go
@@ -0,0 +1,14 @@
+$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 {
diff --git a/lang/go/patches/patch-src_net_cgo__bsd.go b/lang/go/patches/patch-src_net_cgo__bsd.go
new file mode 100644
index 00000000000..ce4bbe3e65f
--- /dev/null
+++ b/lang/go/patches/patch-src_net_cgo__bsd.go
@@ -0,0 +1,15 @@
+$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
+
diff --git a/lang/go/patches/patch-src_net_cgo__stub.go b/lang/go/patches/patch-src_net_cgo__stub.go
new file mode 100644
index 00000000000..0b839dfa0ce
--- /dev/null
+++ b/lang/go/patches/patch-src_net_cgo__stub.go
@@ -0,0 +1,15 @@
+$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.
+
diff --git a/lang/go/patches/patch-src_net_cgo__unix.go b/lang/go/patches/patch-src_net_cgo__unix.go
new file mode 100644
index 00000000000..d9b0e064019
--- /dev/null
+++ b/lang/go/patches/patch-src_net_cgo__unix.go
@@ -0,0 +1,15 @@
+$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
+
diff --git a/lang/go/patches/patch-src_os_user_lookup__unix.go b/lang/go/patches/patch-src_os_user_lookup__unix.go
new file mode 100644
index 00000000000..7cd5286cffb
--- /dev/null
+++ b/lang/go/patches/patch-src_os_user_lookup__unix.go
@@ -0,0 +1,14 @@
+$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>
diff --git a/lang/go/patches/patch-src_runtime_cgo_cgo.go b/lang/go/patches/patch-src_runtime_cgo_cgo.go
new file mode 100644
index 00000000000..a298ba99d21
--- /dev/null
+++ b/lang/go/patches/patch-src_runtime_cgo_cgo.go
@@ -0,0 +1,14 @@
+$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"
diff --git a/lang/go/patches/patch-src_runtime_cgo_gcc__setenv.c b/lang/go/patches/patch-src_runtime_cgo_gcc__setenv.c
new file mode 100644
index 00000000000..666724df7e2
--- /dev/null
+++ b/lang/go/patches/patch-src_runtime_cgo_gcc__setenv.c
@@ -0,0 +1,15 @@
+$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"
+
diff --git a/lang/go/patches/patch-src_runtime_cgo_gcc__solaris__amd64.c b/lang/go/patches/patch-src_runtime_cgo_gcc__solaris__amd64.c
new file mode 100644
index 00000000000..833904c73c5
--- /dev/null
+++ b/lang/go/patches/patch-src_runtime_cgo_gcc__solaris__amd64.c
@@ -0,0 +1,77 @@
+$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;
++}
diff --git a/lang/go/patches/patch-src_runtime_cgo_setenv.c b/lang/go/patches/patch-src_runtime_cgo_setenv.c
new file mode 100644
index 00000000000..af519eb492a
--- /dev/null
+++ b/lang/go/patches/patch-src_runtime_cgo_setenv.c
@@ -0,0 +1,15 @@
+$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
diff --git a/lang/go/patches/patch-src_runtime_netpoll__solaris.c b/lang/go/patches/patch-src_runtime_netpoll__solaris.c
new file mode 100644
index 00000000000..2c88034c0ee
--- /dev/null
+++ b/lang/go/patches/patch-src_runtime_netpoll__solaris.c
@@ -0,0 +1,26 @@
+$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)
+
diff --git a/lang/go/patches/patch-src_runtime_os__solaris.c b/lang/go/patches/patch-src_runtime_os__solaris.c
new file mode 100644
index 00000000000..7266b1e791c
--- /dev/null
+++ b/lang/go/patches/patch-src_runtime_os__solaris.c
@@ -0,0 +1,95 @@
+$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
diff --git a/lang/go/patches/patch-src_runtime_os__solaris.h b/lang/go/patches/patch-src_runtime_os__solaris.h
new file mode 100644
index 00000000000..9c67a40b7eb
--- /dev/null
+++ b/lang/go/patches/patch-src_runtime_os__solaris.h
@@ -0,0 +1,27 @@
+$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);
diff --git a/lang/go/patches/patch-src_runtime_sys__solaris__amd64.s b/lang/go/patches/patch-src_runtime_sys__solaris__amd64.s
new file mode 100644
index 00000000000..0ed1257b063
--- /dev/null
+++ b/lang/go/patches/patch-src_runtime_sys__solaris__amd64.s
@@ -0,0 +1,40 @@
+$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
+
diff --git a/lang/go/patches/patch-src_runtime_thunk__solaris__amd64.s b/lang/go/patches/patch-src_runtime_thunk__solaris__amd64.s
new file mode 100644
index 00000000000..9bc27d73f87
--- /dev/null
+++ b/lang/go/patches/patch-src_runtime_thunk__solaris__amd64.s
@@ -0,0 +1,108 @@
+$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