Update lang/go to version 1.9.
ok ajacoutot@ jasper@
This commit is contained in:
parent
8c3e0ce527
commit
24fbcf9e7e
@ -1,11 +1,10 @@
|
||||
# $OpenBSD: Makefile,v 1.45 2017/08/31 17:05:19 jsing Exp $
|
||||
# $OpenBSD: Makefile,v 1.46 2017/09/03 15:42:25 jsing Exp $
|
||||
|
||||
ONLY_FOR_ARCHS = ${GO_ARCHS}
|
||||
|
||||
COMMENT = Go programming language
|
||||
|
||||
VERSION = 1.8.3
|
||||
REVISION = 1
|
||||
VERSION = 1.9
|
||||
EXTRACT_SUFX = .src.tar.gz
|
||||
DISTNAME = go${VERSION}
|
||||
PKGNAME = go-${VERSION}
|
||||
|
@ -1,2 +1,2 @@
|
||||
SHA256 (go1.8.3.src.tar.gz) = X13qJEfn3P3FD6a5TFEuWL+6VnPAOSWf2EP2iCnZn6Y=
|
||||
SIZE (go1.8.3.src.tar.gz) = 15345996
|
||||
SHA256 (go1.9.src.tar.gz) = pKsikCjtFnuhmGgldRRjYFJk5EhoNiyo56zMi+BX6ZM=
|
||||
SIZE (go1.9.src.tar.gz) = 16377363
|
||||
|
@ -1,7 +1,8 @@
|
||||
$OpenBSD: patch-src_cmd_go_go_test_go,v 1.1 2017/06/04 18:04:03 jsing Exp $
|
||||
--- src/cmd/go/go_test.go.orig Mon Jun 5 03:15:23 2017
|
||||
+++ src/cmd/go/go_test.go Mon Jun 5 03:29:43 2017
|
||||
@@ -3358,6 +3358,9 @@ func TestCgoConsistentResults(t *testing.T) {
|
||||
$OpenBSD: patch-src_cmd_go_go_test_go,v 1.2 2017/09/03 15:42:25 jsing Exp $
|
||||
Index: src/cmd/go/go_test.go
|
||||
--- src/cmd/go/go_test.go.orig
|
||||
+++ src/cmd/go/go_test.go
|
||||
@@ -3475,6 +3475,9 @@ func TestCgoConsistentResults(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "freebsd":
|
||||
testenv.SkipFlaky(t, 15405)
|
||||
|
@ -1,9 +1,9 @@
|
||||
$OpenBSD: patch-src_cmd_go_build_go,v 1.1 2017/08/31 17:05:19 jsing Exp $
|
||||
$OpenBSD: patch-src_cmd_go_internal_work_build_go,v 1.1 2017/09/03 15:42:25 jsing Exp $
|
||||
|
||||
Index: src/cmd/go/build.go
|
||||
--- src/cmd/go/build.go.orig
|
||||
+++ src/cmd/go/build.go
|
||||
@@ -3158,10 +3158,12 @@ func (b *builder) ccompilerCmd(envvar, defcmd, objdir
|
||||
Index: src/cmd/go/internal/work/build.go
|
||||
--- src/cmd/go/internal/work/build.go.orig
|
||||
+++ src/cmd/go/internal/work/build.go
|
||||
@@ -3165,10 +3165,12 @@ func (b *Builder) ccompilerCmd(envvar, defcmd, objdir
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
$OpenBSD: patch-src_cmd_link_internal_ld_data_go,v 1.3 2017/02/23 15:57:42 jsing Exp $
|
||||
--- src/cmd/link/internal/ld/data.go.orig Fri Jan 27 05:54:57 2017
|
||||
+++ src/cmd/link/internal/ld/data.go Mon Jan 23 15:22:25 2017
|
||||
@@ -449,7 +449,7 @@ func relocsym(ctxt *Link, s *Symbol) {
|
||||
case obj.R_TLS_LE:
|
||||
isAndroidX86 := obj.GOOS == "android" && (SysArch.InFamily(sys.AMD64, sys.I386))
|
||||
|
||||
- if Linkmode == LinkExternal && Iself && Headtype != obj.Hopenbsd && !isAndroidX86 {
|
||||
+ if Linkmode == LinkExternal && Iself && !isAndroidX86 {
|
||||
r.Done = 0
|
||||
if r.Sym == nil {
|
||||
r.Sym = ctxt.Tlsg
|
||||
@@ -483,7 +483,7 @@ func relocsym(ctxt *Link, s *Symbol) {
|
||||
case obj.R_TLS_IE:
|
||||
isAndroidX86 := obj.GOOS == "android" && (SysArch.InFamily(sys.AMD64, sys.I386))
|
||||
|
||||
- if Linkmode == LinkExternal && Iself && Headtype != obj.Hopenbsd && !isAndroidX86 {
|
||||
+ if Linkmode == LinkExternal && Iself && !isAndroidX86 {
|
||||
r.Done = 0
|
||||
if r.Sym == nil {
|
||||
r.Sym = ctxt.Tlsg
|
||||
@@ -1566,7 +1566,7 @@ func (ctxt *Link) dodata() {
|
||||
|
||||
if len(data[obj.STLSBSS]) > 0 {
|
||||
var sect *Section
|
||||
- if Iself && (Linkmode == LinkExternal || !*FlagD) && Headtype != obj.Hopenbsd {
|
||||
+ if Iself && (Linkmode == LinkExternal || !*FlagD) {
|
||||
sect = addsection(&Segdata, ".tbss", 06)
|
||||
sect.Align = int32(SysArch.PtrSize)
|
||||
sect.Vaddr = 0
|
@ -1,58 +0,0 @@
|
||||
$OpenBSD: patch-src_cmd_link_internal_ld_elf_go,v 1.4 2017/02/23 15:57:42 jsing Exp $
|
||||
--- src/cmd/link/internal/ld/elf.go.orig Fri Jan 27 05:54:57 2017
|
||||
+++ src/cmd/link/internal/ld/elf.go Mon Jan 23 15:25:39 2017
|
||||
@@ -1894,14 +1894,11 @@ func (ctxt *Link) doelf() {
|
||||
Addstring(shstrtab, ".bss")
|
||||
Addstring(shstrtab, ".noptrbss")
|
||||
|
||||
- // generate .tbss section (except for OpenBSD where it's not supported)
|
||||
- // for dynamic internal linker or external linking, so that various
|
||||
- // binutils could correctly calculate PT_TLS size.
|
||||
- // see https://golang.org/issue/5200.
|
||||
- if Headtype != obj.Hopenbsd {
|
||||
- if !*FlagD || Linkmode == LinkExternal {
|
||||
- Addstring(shstrtab, ".tbss")
|
||||
- }
|
||||
+ // generate .tbss section for dynamic internal linker or external
|
||||
+ // linking, so that various binutils could correctly calculate
|
||||
+ // PT_TLS size. See https://golang.org/issue/5200.
|
||||
+ if !*FlagD || Linkmode == LinkExternal {
|
||||
+ Addstring(shstrtab, ".tbss")
|
||||
}
|
||||
if Headtype == obj.Hnetbsd {
|
||||
Addstring(shstrtab, ".note.netbsd.ident")
|
||||
@@ -2525,23 +2522,18 @@ func Asmbelf(ctxt *Link, symo int64) {
|
||||
/*
|
||||
* Thread-local storage segment (really just size).
|
||||
*/
|
||||
- // Do not emit PT_TLS for OpenBSD since ld.so(1) does
|
||||
- // not currently support it. This is handled
|
||||
- // appropriately in runtime/cgo.
|
||||
- if Headtype != obj.Hopenbsd {
|
||||
- tlssize := uint64(0)
|
||||
- for sect := Segdata.Sect; sect != nil; sect = sect.Next {
|
||||
- if sect.Name == ".tbss" {
|
||||
- tlssize = sect.Length
|
||||
- }
|
||||
+ tlssize := uint64(0)
|
||||
+ for sect := Segdata.Sect; sect != nil; sect = sect.Next {
|
||||
+ if sect.Name == ".tbss" {
|
||||
+ tlssize = sect.Length
|
||||
}
|
||||
- if tlssize != 0 {
|
||||
- ph := newElfPhdr()
|
||||
- ph.type_ = PT_TLS
|
||||
- ph.flags = PF_R
|
||||
- ph.memsz = tlssize
|
||||
- ph.align = uint64(SysArch.RegSize)
|
||||
- }
|
||||
+ }
|
||||
+ if tlssize != 0 {
|
||||
+ ph := newElfPhdr()
|
||||
+ ph.type_ = PT_TLS
|
||||
+ ph.flags = PF_R
|
||||
+ ph.memsz = tlssize
|
||||
+ ph.align = uint64(SysArch.RegSize)
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
$OpenBSD: patch-src_cmd_link_internal_ld_ldelf_go,v 1.1 2017/06/04 18:04:03 jsing Exp $
|
||||
--- src/cmd/link/internal/ld/ldelf.go.orig Thu May 25 04:15:12 2017
|
||||
+++ src/cmd/link/internal/ld/ldelf.go Mon Jun 5 01:58:33 2017
|
||||
$OpenBSD: patch-src_cmd_link_internal_ld_ldelf_go,v 1.2 2017/09/03 15:42:25 jsing Exp $
|
||||
Index: src/cmd/link/internal/ld/ldelf.go
|
||||
--- src/cmd/link/internal/ld/ldelf.go.orig
|
||||
+++ src/cmd/link/internal/ld/ldelf.go
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
@ -9,9 +10,9 @@ $OpenBSD: patch-src_cmd_link_internal_ld_ldelf_go,v 1.1 2017/06/04 18:04:03 jsin
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
@@ -1053,6 +1054,13 @@ func readelfsym(ctxt *Link, elfobj *ElfObj, i int, sym
|
||||
@@ -1062,6 +1063,13 @@ func readelfsym(ctxt *Link, elfobj *ElfObj, i int, sym
|
||||
if s != nil && sym.other == 2 {
|
||||
s.Type |= obj.SHIDDEN
|
||||
s.Type |= SHIDDEN
|
||||
s.Attr |= AttrDuplicateOK
|
||||
+ }
|
||||
+
|
||||
@ -19,7 +20,7 @@ $OpenBSD: patch-src_cmd_link_internal_ld_ldelf_go,v 1.1 2017/06/04 18:04:03 jsin
|
||||
+ // __guard_local symbols, which is tripping up the Go linker.
|
||||
+ // As a workaround, mark the symbol as visible for the time being.
|
||||
+ if s != nil && runtime.GOOS == "openbsd" && sym.name == "__guard_local" {
|
||||
+ s.Type &^= obj.SHIDDEN
|
||||
+ s.Type &^= SHIDDEN
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
$OpenBSD: patch-src_cmd_link_internal_ld_lib_go,v 1.5 2017/08/31 17:05:19 jsing Exp $
|
||||
$OpenBSD: patch-src_cmd_link_internal_ld_lib_go,v 1.6 2017/09/03 15:42:25 jsing Exp $
|
||||
Index: src/cmd/link/internal/ld/lib.go
|
||||
--- src/cmd/link/internal/ld/lib.go.orig
|
||||
+++ src/cmd/link/internal/ld/lib.go
|
||||
@@ -563,7 +563,13 @@ func (ctxt *Link) loadlib() {
|
||||
@@ -580,7 +580,13 @@ func (ctxt *Link) loadlib() {
|
||||
}
|
||||
if any {
|
||||
if *flagLibGCC == "" {
|
||||
@ -16,12 +16,3 @@ Index: src/cmd/link/internal/ld/lib.go
|
||||
}
|
||||
if *flagLibGCC != "none" {
|
||||
hostArchive(ctxt, *flagLibGCC)
|
||||
@@ -1958,7 +1964,7 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, st
|
||||
put(ctxt, s, s.Extname, UndefinedSym, 0, nil)
|
||||
|
||||
case obj.STLSBSS:
|
||||
- if Linkmode == LinkExternal && Headtype != obj.Hopenbsd {
|
||||
+ if Linkmode == LinkExternal {
|
||||
put(ctxt, s, s.Name, TLSSym, Symaddr(s), s.Gotype)
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
$OpenBSD: patch-src_runtime_cgo_gcc_libinit_c,v 1.1 2017/02/23 15:57:42 jsing Exp $
|
||||
--- src/runtime/cgo/gcc_libinit.c.orig Mon Jan 23 15:40:21 2017
|
||||
+++ src/runtime/cgo/gcc_libinit.c Mon Jan 23 15:41:06 2017
|
||||
@@ -3,7 +3,7 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build cgo
|
||||
-// +build darwin dragonfly freebsd linux netbsd solaris
|
||||
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
@ -1,78 +0,0 @@
|
||||
$OpenBSD: patch-src_runtime_cgo_gcc_libinit_openbsd_c,v 1.1 2017/02/23 15:57:42 jsing Exp $
|
||||
--- src/runtime/cgo/gcc_libinit_openbsd.c.orig Mon Jan 23 15:40:29 2017
|
||||
+++ src/runtime/cgo/gcc_libinit_openbsd.c Mon Jan 23 15:41:12 2017
|
||||
@@ -1,74 +0,0 @@
|
||||
-// Copyright 2015 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 <sys/types.h>
|
||||
-#include <errno.h>
|
||||
-#include <pthread.h>
|
||||
-#include <stdio.h>
|
||||
-#include <stdlib.h>
|
||||
-#include "libcgo.h"
|
||||
-
|
||||
-// The context function, used when tracing back C calls into Go.
|
||||
-static void (*cgo_context_function)(struct context_arg*);
|
||||
-
|
||||
-void
|
||||
-x_cgo_sys_thread_create(void* (*func)(void*), void* arg) {
|
||||
- fprintf(stderr, "x_cgo_sys_thread_create not implemented");
|
||||
- abort();
|
||||
-}
|
||||
-
|
||||
-uintptr_t
|
||||
-_cgo_wait_runtime_init_done() {
|
||||
- void (*pfn)(struct context_arg*);
|
||||
-
|
||||
- // TODO(spetrovic): implement this method.
|
||||
-
|
||||
- pfn = _cgo_get_context_function();
|
||||
- if (pfn != nil) {
|
||||
- struct context_arg arg;
|
||||
-
|
||||
- arg.Context = 0;
|
||||
- (*pfn)(&arg);
|
||||
- return arg.Context;
|
||||
- }
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-void
|
||||
-x_cgo_notify_runtime_init_done(void* dummy) {
|
||||
- // TODO(spetrovic): implement this method.
|
||||
-}
|
||||
-
|
||||
-// Sets the context function to call to record the traceback context
|
||||
-// when calling a Go function from C code. Called from runtime.SetCgoTraceback.
|
||||
-void x_cgo_set_context_function(void (*context)(struct context_arg*)) {
|
||||
- // TODO(iant): Needs synchronization.
|
||||
- cgo_context_function = context;
|
||||
-}
|
||||
-
|
||||
-// Gets the context function.
|
||||
-void (*(_cgo_get_context_function(void)))(struct context_arg*) {
|
||||
- return cgo_context_function;
|
||||
-}
|
||||
-
|
||||
-// _cgo_try_pthread_create retries sys_pthread_create if it fails with
|
||||
-// EAGAIN.
|
||||
-int
|
||||
-_cgo_openbsd_try_pthread_create(int (*sys_pthread_create)(pthread_t*, const pthread_attr_t*, void* (*)(void*), void*),
|
||||
- pthread_t* thread, const pthread_attr_t* attr, void* (*pfn)(void*), void* arg) {
|
||||
- int tries;
|
||||
- int err;
|
||||
- struct timespec ts;
|
||||
-
|
||||
- for (tries = 0; tries < 100; tries++) {
|
||||
- err = sys_pthread_create(thread, attr, pfn, arg);
|
||||
- if (err != EAGAIN) {
|
||||
- return err;
|
||||
- }
|
||||
- ts.tv_sec = 0;
|
||||
- ts.tv_nsec = (tries + 1) * 1000 * 1000; // Milliseconds.
|
||||
- nanosleep(&ts, nil);
|
||||
- }
|
||||
- return EAGAIN;
|
||||
-}
|
@ -1,174 +0,0 @@
|
||||
$OpenBSD: patch-src_runtime_cgo_gcc_openbsd_386_c,v 1.3 2017/02/23 15:57:42 jsing Exp $
|
||||
--- src/runtime/cgo/gcc_openbsd_386.c.orig Fri Jan 27 05:54:59 2017
|
||||
+++ src/runtime/cgo/gcc_openbsd_386.c Mon Jan 23 15:19:45 2017
|
||||
@@ -3,8 +3,7 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
#include <sys/types.h>
|
||||
-#include <dlfcn.h>
|
||||
-#include <errno.h>
|
||||
+#include <sys/signal.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
@@ -14,125 +13,6 @@
|
||||
static void* threadentry(void*);
|
||||
static void (*setg_gcc)(void*);
|
||||
|
||||
-// TCB_SIZE is sizeof(struct thread_control_block), as defined in
|
||||
-// /usr/src/lib/librthread/tcb.h on OpenBSD 5.9 and earlier.
|
||||
-#define TCB_SIZE (4 * sizeof(void *))
|
||||
-
|
||||
-// TIB_SIZE is sizeof(struct tib), as defined in
|
||||
-// /usr/include/tib.h on OpenBSD 6.0 and later.
|
||||
-#define TIB_SIZE (4 * sizeof(void *) + 6 * sizeof(int))
|
||||
-
|
||||
-// TLS_SIZE is the size of TLS needed for Go.
|
||||
-#define TLS_SIZE (2 * sizeof(void *))
|
||||
-
|
||||
-void *__get_tcb(void);
|
||||
-void __set_tcb(void *);
|
||||
-
|
||||
-static int (*sys_pthread_create)(pthread_t *thread, const pthread_attr_t *attr,
|
||||
- void *(*start_routine)(void *), void *arg);
|
||||
-
|
||||
-struct thread_args {
|
||||
- void *(*func)(void *);
|
||||
- void *arg;
|
||||
-};
|
||||
-
|
||||
-static int has_tib = 0;
|
||||
-
|
||||
-static void
|
||||
-tcb_fixup(int mainthread)
|
||||
-{
|
||||
- void *tls, *newtcb, *oldtcb;
|
||||
- size_t tls_size, tcb_size;
|
||||
-
|
||||
- // TODO(jsing): Remove once OpenBSD 6.1 is released and OpenBSD 5.9 is
|
||||
- // no longer supported.
|
||||
-
|
||||
- // The OpenBSD ld.so(1) does not currently support PT_TLS. As a result,
|
||||
- // we need to allocate our own TLS space while preserving the existing
|
||||
- // TCB or TIB that has been setup via librthread.
|
||||
-
|
||||
- tcb_size = has_tib ? TIB_SIZE : TCB_SIZE;
|
||||
- tls_size = TLS_SIZE + tcb_size;
|
||||
- tls = malloc(tls_size);
|
||||
- if(tls == NULL)
|
||||
- abort();
|
||||
-
|
||||
- // The signal trampoline expects the TLS slots to be zeroed.
|
||||
- bzero(tls, TLS_SIZE);
|
||||
-
|
||||
- oldtcb = __get_tcb();
|
||||
- newtcb = tls + TLS_SIZE;
|
||||
- bcopy(oldtcb, newtcb, tcb_size);
|
||||
- if(has_tib) {
|
||||
- // Fix up self pointer.
|
||||
- *(uintptr_t *)(newtcb) = (uintptr_t)newtcb;
|
||||
- }
|
||||
- __set_tcb(newtcb);
|
||||
-
|
||||
- // NOTE(jsing, minux): we can't free oldtcb without causing double-free
|
||||
- // problem. so newtcb will be memory leaks. Get rid of this when OpenBSD
|
||||
- // has proper support for PT_TLS.
|
||||
-}
|
||||
-
|
||||
-static void *
|
||||
-thread_start_wrapper(void *arg)
|
||||
-{
|
||||
- struct thread_args args = *(struct thread_args *)arg;
|
||||
-
|
||||
- free(arg);
|
||||
- tcb_fixup(0);
|
||||
-
|
||||
- return args.func(args.arg);
|
||||
-}
|
||||
-
|
||||
-static void init_pthread_wrapper(void) {
|
||||
- void *handle;
|
||||
-
|
||||
- // Locate symbol for the system pthread_create function.
|
||||
- handle = dlopen("libpthread.so", RTLD_LAZY);
|
||||
- if(handle == NULL) {
|
||||
- fprintf(stderr, "runtime/cgo: dlopen failed to load libpthread: %s\n", dlerror());
|
||||
- abort();
|
||||
- }
|
||||
- sys_pthread_create = dlsym(handle, "pthread_create");
|
||||
- if(sys_pthread_create == NULL) {
|
||||
- fprintf(stderr, "runtime/cgo: dlsym failed to find pthread_create: %s\n", dlerror());
|
||||
- abort();
|
||||
- }
|
||||
- // _rthread_init is hidden in OpenBSD librthread that has TIB.
|
||||
- if(dlsym(handle, "_rthread_init") == NULL) {
|
||||
- has_tib = 1;
|
||||
- }
|
||||
- dlclose(handle);
|
||||
-}
|
||||
-
|
||||
-static pthread_once_t init_pthread_wrapper_once = PTHREAD_ONCE_INIT;
|
||||
-
|
||||
-int
|
||||
-pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
- void *(*start_routine)(void *), void *arg)
|
||||
-{
|
||||
- struct thread_args *p;
|
||||
-
|
||||
- // we must initialize our wrapper in pthread_create, because it is valid to call
|
||||
- // pthread_create in a static constructor, and in fact, our test for issue 9456
|
||||
- // does just that.
|
||||
- if(pthread_once(&init_pthread_wrapper_once, init_pthread_wrapper) != 0) {
|
||||
- fprintf(stderr, "runtime/cgo: failed to initialize pthread_create wrapper\n");
|
||||
- abort();
|
||||
- }
|
||||
-
|
||||
- p = malloc(sizeof(*p));
|
||||
- if(p == NULL) {
|
||||
- errno = ENOMEM;
|
||||
- return -1;
|
||||
- }
|
||||
- p->func = start_routine;
|
||||
- p->arg = arg;
|
||||
-
|
||||
- return sys_pthread_create(thread, attr, thread_start_wrapper, p);
|
||||
-}
|
||||
-
|
||||
void
|
||||
x_cgo_init(G *g, void (*setg)(void*))
|
||||
{
|
||||
@@ -144,16 +24,8 @@ x_cgo_init(G *g, void (*setg)(void*))
|
||||
pthread_attr_getstacksize(&attr, &size);
|
||||
g->stacklo = (uintptr)&attr - size + 4096;
|
||||
pthread_attr_destroy(&attr);
|
||||
-
|
||||
- if(pthread_once(&init_pthread_wrapper_once, init_pthread_wrapper) != 0) {
|
||||
- fprintf(stderr, "runtime/cgo: failed to initialize pthread_create wrapper\n");
|
||||
- abort();
|
||||
- }
|
||||
-
|
||||
- tcb_fixup(1);
|
||||
}
|
||||
|
||||
-
|
||||
void
|
||||
_cgo_sys_thread_start(ThreadStart *ts)
|
||||
{
|
||||
@@ -171,7 +43,7 @@ _cgo_sys_thread_start(ThreadStart *ts)
|
||||
|
||||
// Leave stacklo=0 and set stackhi=size; mstack will do the rest.
|
||||
ts->g->stackhi = size;
|
||||
- err = _cgo_openbsd_try_pthread_create(sys_pthread_create, &p, &attr, threadentry, ts);
|
||||
+ err = _cgo_try_pthread_create(&p, &attr, threadentry, ts);
|
||||
|
||||
pthread_sigmask(SIG_SETMASK, &oset, nil);
|
||||
|
||||
@@ -185,8 +57,6 @@ static void*
|
||||
threadentry(void *v)
|
||||
{
|
||||
ThreadStart ts;
|
||||
-
|
||||
- tcb_fixup(0);
|
||||
|
||||
ts = *(ThreadStart*)v;
|
||||
free(v);
|
@ -1,174 +0,0 @@
|
||||
$OpenBSD: patch-src_runtime_cgo_gcc_openbsd_amd64_c,v 1.3 2017/02/23 15:57:42 jsing Exp $
|
||||
--- src/runtime/cgo/gcc_openbsd_amd64.c.orig Fri Jan 27 05:54:59 2017
|
||||
+++ src/runtime/cgo/gcc_openbsd_amd64.c Mon Jan 23 15:19:58 2017
|
||||
@@ -3,8 +3,7 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
#include <sys/types.h>
|
||||
-#include <dlfcn.h>
|
||||
-#include <errno.h>
|
||||
+#include <sys/signal.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
@@ -14,125 +13,6 @@
|
||||
static void* threadentry(void*);
|
||||
static void (*setg_gcc)(void*);
|
||||
|
||||
-// TCB_SIZE is sizeof(struct thread_control_block), as defined in
|
||||
-// /usr/src/lib/librthread/tcb.h on OpenBSD 5.9 and earlier.
|
||||
-#define TCB_SIZE (4 * sizeof(void *))
|
||||
-
|
||||
-// TIB_SIZE is sizeof(struct tib), as defined in
|
||||
-// /usr/include/tib.h on OpenBSD 6.0 and later.
|
||||
-#define TIB_SIZE (4 * sizeof(void *) + 6 * sizeof(int))
|
||||
-
|
||||
-// TLS_SIZE is the size of TLS needed for Go.
|
||||
-#define TLS_SIZE (2 * sizeof(void *))
|
||||
-
|
||||
-void *__get_tcb(void);
|
||||
-void __set_tcb(void *);
|
||||
-
|
||||
-static int (*sys_pthread_create)(pthread_t *thread, const pthread_attr_t *attr,
|
||||
- void *(*start_routine)(void *), void *arg);
|
||||
-
|
||||
-struct thread_args {
|
||||
- void *(*func)(void *);
|
||||
- void *arg;
|
||||
-};
|
||||
-
|
||||
-static int has_tib = 0;
|
||||
-
|
||||
-static void
|
||||
-tcb_fixup(int mainthread)
|
||||
-{
|
||||
- void *tls, *newtcb, *oldtcb;
|
||||
- size_t tls_size, tcb_size;
|
||||
-
|
||||
- // TODO(jsing): Remove once OpenBSD 6.1 is released and OpenBSD 5.9 is
|
||||
- // no longer supported.
|
||||
-
|
||||
- // The OpenBSD ld.so(1) does not currently support PT_TLS. As a result,
|
||||
- // we need to allocate our own TLS space while preserving the existing
|
||||
- // TCB or TIB that has been setup via librthread.
|
||||
-
|
||||
- tcb_size = has_tib ? TIB_SIZE : TCB_SIZE;
|
||||
- tls_size = TLS_SIZE + tcb_size;
|
||||
- tls = malloc(tls_size);
|
||||
- if(tls == NULL)
|
||||
- abort();
|
||||
-
|
||||
- // The signal trampoline expects the TLS slots to be zeroed.
|
||||
- bzero(tls, TLS_SIZE);
|
||||
-
|
||||
- oldtcb = __get_tcb();
|
||||
- newtcb = tls + TLS_SIZE;
|
||||
- bcopy(oldtcb, newtcb, tcb_size);
|
||||
- if(has_tib) {
|
||||
- // Fix up self pointer.
|
||||
- *(uintptr_t *)(newtcb) = (uintptr_t)newtcb;
|
||||
- }
|
||||
- __set_tcb(newtcb);
|
||||
-
|
||||
- // NOTE(jsing, minux): we can't free oldtcb without causing double-free
|
||||
- // problem. so newtcb will be memory leaks. Get rid of this when OpenBSD
|
||||
- // has proper support for PT_TLS.
|
||||
-}
|
||||
-
|
||||
-static void *
|
||||
-thread_start_wrapper(void *arg)
|
||||
-{
|
||||
- struct thread_args args = *(struct thread_args *)arg;
|
||||
-
|
||||
- free(arg);
|
||||
- tcb_fixup(0);
|
||||
-
|
||||
- return args.func(args.arg);
|
||||
-}
|
||||
-
|
||||
-static void init_pthread_wrapper(void) {
|
||||
- void *handle;
|
||||
-
|
||||
- // Locate symbol for the system pthread_create function.
|
||||
- handle = dlopen("libpthread.so", RTLD_LAZY);
|
||||
- if(handle == NULL) {
|
||||
- fprintf(stderr, "runtime/cgo: dlopen failed to load libpthread: %s\n", dlerror());
|
||||
- abort();
|
||||
- }
|
||||
- sys_pthread_create = dlsym(handle, "pthread_create");
|
||||
- if(sys_pthread_create == NULL) {
|
||||
- fprintf(stderr, "runtime/cgo: dlsym failed to find pthread_create: %s\n", dlerror());
|
||||
- abort();
|
||||
- }
|
||||
- // _rthread_init is hidden in OpenBSD librthread that has TIB.
|
||||
- if(dlsym(handle, "_rthread_init") == NULL) {
|
||||
- has_tib = 1;
|
||||
- }
|
||||
- dlclose(handle);
|
||||
-}
|
||||
-
|
||||
-static pthread_once_t init_pthread_wrapper_once = PTHREAD_ONCE_INIT;
|
||||
-
|
||||
-int
|
||||
-pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
- void *(*start_routine)(void *), void *arg)
|
||||
-{
|
||||
- struct thread_args *p;
|
||||
-
|
||||
- // we must initialize our wrapper in pthread_create, because it is valid to call
|
||||
- // pthread_create in a static constructor, and in fact, our test for issue 9456
|
||||
- // does just that.
|
||||
- if(pthread_once(&init_pthread_wrapper_once, init_pthread_wrapper) != 0) {
|
||||
- fprintf(stderr, "runtime/cgo: failed to initialize pthread_create wrapper\n");
|
||||
- abort();
|
||||
- }
|
||||
-
|
||||
- p = malloc(sizeof(*p));
|
||||
- if(p == NULL) {
|
||||
- errno = ENOMEM;
|
||||
- return -1;
|
||||
- }
|
||||
- p->func = start_routine;
|
||||
- p->arg = arg;
|
||||
-
|
||||
- return sys_pthread_create(thread, attr, thread_start_wrapper, p);
|
||||
-}
|
||||
-
|
||||
void
|
||||
x_cgo_init(G *g, void (*setg)(void*))
|
||||
{
|
||||
@@ -144,16 +24,8 @@ x_cgo_init(G *g, void (*setg)(void*))
|
||||
pthread_attr_getstacksize(&attr, &size);
|
||||
g->stacklo = (uintptr)&attr - size + 4096;
|
||||
pthread_attr_destroy(&attr);
|
||||
-
|
||||
- if(pthread_once(&init_pthread_wrapper_once, init_pthread_wrapper) != 0) {
|
||||
- fprintf(stderr, "runtime/cgo: failed to initialize pthread_create wrapper\n");
|
||||
- abort();
|
||||
- }
|
||||
-
|
||||
- tcb_fixup(1);
|
||||
}
|
||||
|
||||
-
|
||||
void
|
||||
_cgo_sys_thread_start(ThreadStart *ts)
|
||||
{
|
||||
@@ -171,7 +43,7 @@ _cgo_sys_thread_start(ThreadStart *ts)
|
||||
|
||||
// Leave stacklo=0 and set stackhi=size; mstack will do the rest.
|
||||
ts->g->stackhi = size;
|
||||
- err = _cgo_openbsd_try_pthread_create(sys_pthread_create, &p, &attr, threadentry, ts);
|
||||
+ err = _cgo_try_pthread_create(&p, &attr, threadentry, ts);
|
||||
|
||||
pthread_sigmask(SIG_SETMASK, &oset, nil);
|
||||
|
||||
@@ -185,8 +57,6 @@ static void*
|
||||
threadentry(void *v)
|
||||
{
|
||||
ThreadStart ts;
|
||||
-
|
||||
- tcb_fixup(0);
|
||||
|
||||
ts = *(ThreadStart*)v;
|
||||
free(v);
|
@ -1,30 +0,0 @@
|
||||
$OpenBSD: patch-src_runtime_cgo_openbsd_go,v 1.1 2016/05/16 13:50:02 jsing Exp $
|
||||
--- src/runtime/cgo/openbsd.go.orig Thu Feb 18 07:35:22 2016
|
||||
+++ src/runtime/cgo/openbsd.go Sat May 14 02:22:05 2016
|
||||
@@ -8,24 +8,13 @@ package cgo
|
||||
|
||||
import _ "unsafe" // for go:linkname
|
||||
|
||||
-// Supply environ, __progname and __guard_local, because
|
||||
-// we don't link against the standard OpenBSD crt0.o and
|
||||
-// the libc dynamic library needs them.
|
||||
+// Supply __guard_local because we don't link against the standard
|
||||
+// OpenBSD crt0.o and the libc dynamic library needs it.
|
||||
|
||||
-//go:linkname _environ environ
|
||||
-//go:linkname _progname __progname
|
||||
//go:linkname _guard_local __guard_local
|
||||
|
||||
-var _environ uintptr
|
||||
-var _progname uintptr
|
||||
var _guard_local uintptr
|
||||
|
||||
-//go:cgo_export_dynamic environ environ
|
||||
-//go:cgo_export_dynamic __progname __progname
|
||||
-
|
||||
// This is normally marked as hidden and placed in the
|
||||
// .openbsd.randomdata section.
|
||||
//go:cgo_export_dynamic __guard_local __guard_local
|
||||
-
|
||||
-// We override pthread_create to support PT_TLS.
|
||||
-//go:cgo_export_dynamic pthread_create pthread_create
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user