pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/lang/go14 go14: fix bootstrap for newer openbsd.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/45931a0c65b7
branches:  trunk
changeset: 322256:45931a0c65b7
user:      maya <maya%pkgsrc.org@localhost>
date:      Sat Apr 13 23:09:40 2019 +0000

description:
go14: fix bootstrap for newer openbsd.

openbsd requires mapping the stack with MAP_STACK. binaries not doing this
will not run. patch taken from openbsd ports, via sjmulder.

I modified it to use GOOS_openbsd, because other OSes are not provided
an implementation of sysMarkStack.

Bump PKGREVISION.

diffstat:

 lang/go14/Makefile                                         |   4 +-
 lang/go14/distinfo                                         |   8 +++-
 lang/go14/patches/patch-src_runtime_defs__openbsd__386.h   |  16 ++++++++
 lang/go14/patches/patch-src_runtime_defs__openbsd__amd64.h |  16 ++++++++
 lang/go14/patches/patch-src_runtime_malloc.h               |  16 ++++++++
 lang/go14/patches/patch-src_runtime_mem__openbsd.c         |  26 ++++++++++++++
 lang/go14/patches/patch-src_runtime_os__openbsd.c          |  17 +++++++++
 lang/go14/patches/patch-src_runtime_stack.c                |  26 ++++++++++++++
 8 files changed, 126 insertions(+), 3 deletions(-)

diffs (187 lines):

diff -r 88451eada08b -r 45931a0c65b7 lang/go14/Makefile
--- a/lang/go14/Makefile        Sat Apr 13 14:30:42 2019 +0000
+++ b/lang/go14/Makefile        Sat Apr 13 23:09:40 2019 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.17 2018/08/22 09:45:20 wiz Exp $
+# $NetBSD: Makefile,v 1.18 2019/04/13 23:09:40 maya Exp $
 
 .include "../../lang/go/version.mk"
 
 DISTNAME=      go${GO14_VERSION}.src
 PKGNAME=       go14-${GO14_VERSION}
-PKGREVISION=   7
+PKGREVISION=   9
 CATEGORIES=    lang
 MASTER_SITES=  https://storage.googleapis.com/golang/
 PATCH_SITES=   https://codereview.appspot.com/download/
diff -r 88451eada08b -r 45931a0c65b7 lang/go14/distinfo
--- a/lang/go14/distinfo        Sat Apr 13 14:30:42 2019 +0000
+++ b/lang/go14/distinfo        Sat Apr 13 23:09:40 2019 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.10 2018/01/20 20:44:49 christos Exp $
+$NetBSD: distinfo,v 1.11 2019/04/13 23:09:40 maya Exp $
 
 SHA1 (go1.4.3.src.tar.gz) = 486db10dc571a55c8d795365070f66d343458c48
 RMD160 (go1.4.3.src.tar.gz) = b1fbb2805a777c8107e7c946f36a881303ac5e35
@@ -38,14 +38,20 @@
 SHA1 (patch-src_runtime_debug__netbsd.go) = 3a54698e749dcd362e5fe4284a4c1f59d654b095
 SHA1 (patch-src_runtime_defs__netbsd.go) = 5f433bb92bd50707fcde5f941e9ca084eac4f659
 SHA1 (patch-src_runtime_defs__netbsd__arm.h) = 150973e3fdb118e11fadea910f7e9f39a70b6067
+SHA1 (patch-src_runtime_defs__openbsd__386.h) = 314a5bdc4ff0ee5f9fb969cdb134fe6183acebb6
+SHA1 (patch-src_runtime_defs__openbsd__amd64.h) = 72335c404604df53b943f3bb3d1088ae784fef0e
+SHA1 (patch-src_runtime_malloc.h) = c41776870b4d95657ad45711b5d921cda4febd29
+SHA1 (patch-src_runtime_mem__openbsd.c) = 2800a500d3bd5bde0bb3a05ac6aec5630b098bca
 SHA1 (patch-src_runtime_mgc0.c) = 6cd1a52376efbf3f825fc511044af4a82528eccc
 SHA1 (patch-src_runtime_mheap.c) = 646f4ba1abf407936ec6c3c0783dd59922079fe3
 SHA1 (patch-src_runtime_netpoll__solaris.c) = ae399518bb02d6b898734a52dfa7fe18f041e1ec
 SHA1 (patch-src_runtime_os__netbsd.c) = 8bb3a4612f5693727f66f6d3a16261e9087b01f0
+SHA1 (patch-src_runtime_os__openbsd.c) = a32f610eba883d17140aea8639953f76593266c0
 SHA1 (patch-src_runtime_os__solaris.c) = eec5b293fe4a72f58e4cd51cd23ea6e6fce714b6
 SHA1 (patch-src_runtime_os__solaris.h) = c0a39aa6ab57eca7056178c87ebb00bb21236499
 SHA1 (patch-src_runtime_proc.c) = 0167ab97ea9229f57d21c549201c2d17965e4c69
 SHA1 (patch-src_runtime_runtime.h) = ab89a3da0870c346529cfe5b8bda202aba0b59f7
+SHA1 (patch-src_runtime_stack.c) = 6bb75bb7aa725a98d2b39b015e8e5692ed26be24
 SHA1 (patch-src_runtime_sys__darwin__386.s) = e352e039bba8435a48b88c76290b245731c299ed
 SHA1 (patch-src_runtime_sys__darwin__amd64.s) = 3eccddc8228657db1480393f8476ddd68ac942ff
 SHA1 (patch-src_runtime_sys__solaris__amd64.s) = 88f2e3fc43b0d6e4f17ef06d3f4f27cfed3103c6
diff -r 88451eada08b -r 45931a0c65b7 lang/go14/patches/patch-src_runtime_defs__openbsd__386.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/go14/patches/patch-src_runtime_defs__openbsd__386.h  Sat Apr 13 23:09:40 2019 +0000
@@ -0,0 +1,16 @@
+$NetBSD: patch-src_runtime_defs__openbsd__386.h,v 1.1 2019/04/13 23:09:40 maya Exp $
+$OpenBSD: patch-src_runtime_defs_openbsd_386_h,v 1.1 2018/04/05 17:47:30 jsing Exp $
+
+OpenBSD 6.4 needs stack pages to be mapped with MAP_STACK.
+
+Index: src/runtime/defs_openbsd_386.h
+--- src/runtime/defs_openbsd_386.h.orig
++++ src/runtime/defs_openbsd_386.h
+@@ -14,6 +14,7 @@ enum {
+       MAP_ANON        = 0x1000,
+       MAP_PRIVATE     = 0x2,
+       MAP_FIXED       = 0x10,
++      MAP_STACK       = 0x4000,
+ 
+       MADV_FREE       = 0x6,
+ 
diff -r 88451eada08b -r 45931a0c65b7 lang/go14/patches/patch-src_runtime_defs__openbsd__amd64.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/go14/patches/patch-src_runtime_defs__openbsd__amd64.h        Sat Apr 13 23:09:40 2019 +0000
@@ -0,0 +1,16 @@
+$NetBSD: patch-src_runtime_defs__openbsd__amd64.h,v 1.1 2019/04/13 23:09:40 maya Exp $
+$OpenBSD: patch-src_runtime_defs_openbsd_amd64_h,v 1.1 2018/04/05 17:47:30 jsing Exp $
+
+OpenBSD 6.4 needs stack pages to be mapped with MAP_STACK.
+
+Index: src/runtime/defs_openbsd_amd64.h
+--- src/runtime/defs_openbsd_amd64.h.orig
++++ src/runtime/defs_openbsd_amd64.h
+@@ -14,6 +14,7 @@ enum {
+       MAP_ANON        = 0x1000,
+       MAP_PRIVATE     = 0x2,
+       MAP_FIXED       = 0x10,
++      MAP_STACK       = 0x4000,
+ 
+       MADV_FREE       = 0x6,
+ 
diff -r 88451eada08b -r 45931a0c65b7 lang/go14/patches/patch-src_runtime_malloc.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/go14/patches/patch-src_runtime_malloc.h      Sat Apr 13 23:09:40 2019 +0000
@@ -0,0 +1,16 @@
+$NetBSD: patch-src_runtime_malloc.h,v 1.1 2019/04/13 23:09:40 maya Exp $
+$OpenBSD: patch-src_runtime_malloc_h,v 1.1 2018/04/05 17:47:30 jsing Exp $
+
+OpenBSD 6.4 needs stack pages to be mapped with MAP_STACK.
+
+Index: src/runtime/malloc.h
+--- src/runtime/malloc.h.orig
++++ src/runtime/malloc.h
+@@ -197,6 +197,7 @@ struct MLink
+ // if accessed.  Used only for debugging the runtime.
+ 
+ void* runtime·sysAlloc(uintptr nbytes, uint64 *stat);
++void  runtime·sysMarkStack(void *v, uintptr nbytes);
+ void  runtime·SysFree(void *v, uintptr nbytes, uint64 *stat);
+ void  runtime·SysUnused(void *v, uintptr nbytes);
+ void  runtime·SysUsed(void *v, uintptr nbytes);
diff -r 88451eada08b -r 45931a0c65b7 lang/go14/patches/patch-src_runtime_mem__openbsd.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/go14/patches/patch-src_runtime_mem__openbsd.c        Sat Apr 13 23:09:40 2019 +0000
@@ -0,0 +1,26 @@
+$NetBSD: patch-src_runtime_mem__openbsd.c,v 1.1 2019/04/13 23:09:40 maya Exp $
+$OpenBSD: patch-src_runtime_mem_openbsd_c,v 1.1 2018/04/05 17:47:30 jsing Exp $
+
+OpenBSD 6.4 needs stack pages to be mapped with MAP_STACK.
+
+Index: src/runtime/mem_openbsd.c
+--- src/runtime/mem_openbsd.c.orig
++++ src/runtime/mem_openbsd.c
+@@ -27,6 +27,17 @@ runtime·sysAlloc(uintptr n, uint64 *stat)
+       return v;
+ }
+ 
++#pragma textflag NOSPLIT
++void
++runtime·sysMarkStack(void *v, uintptr n)
++{
++      void *p;
++
++      p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_ANON|MAP_PRIVATE|MAP_STACK, -1, 0);
++      if (p == ((void *)-1) || p != v)
++              runtime·throw("runtime: failed to mark stack");
++}
++
+ void
+ runtime·SysUnused(void *v, uintptr n)
+ {
diff -r 88451eada08b -r 45931a0c65b7 lang/go14/patches/patch-src_runtime_os__openbsd.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/go14/patches/patch-src_runtime_os__openbsd.c Sat Apr 13 23:09:40 2019 +0000
@@ -0,0 +1,17 @@
+$NetBSD: patch-src_runtime_os__openbsd.c,v 1.1 2019/04/13 23:09:40 maya Exp $
+$OpenBSD: patch-src_runtime_os_openbsd_c,v 1.1 2018/04/05 17:47:30 jsing Exp $
+
+OpenBSD 6.4 needs stack pages to be mapped with MAP_STACK.
+
+Index: src/runtime/os_openbsd.c
+--- src/runtime/os_openbsd.c.orig
++++ src/runtime/os_openbsd.c
+@@ -167,7 +167,7 @@ runtime·newosproc(M *mp, void *stk)
+ 
+       param.tf_tcb = (byte*)&mp->tls[0];
+       param.tf_tid = (int32*)&mp->procid;
+-      param.tf_stack = stk;
++      param.tf_stack = (void*)((uintptr)stk - 8);
+ 
+       oset = runtime·sigprocmask(SIG_SETMASK, sigset_all);
+       ret = runtime·tfork(&param, sizeof(param), mp, mp->g0, runtime·mstart);
diff -r 88451eada08b -r 45931a0c65b7 lang/go14/patches/patch-src_runtime_stack.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/go14/patches/patch-src_runtime_stack.c       Sat Apr 13 23:09:40 2019 +0000
@@ -0,0 +1,26 @@
+$NetBSD: patch-src_runtime_stack.c,v 1.1 2019/04/13 23:09:40 maya Exp $
+
+OpenBSD 6.4 needs stack pages to be mapped with MAP_STACK.
+
+--- src/runtime/stack.c.orig   2015-09-23 04:37:37.000000000 +0000
++++ src/runtime/stack.c
+@@ -67,6 +67,9 @@ poolalloc(uint8 order)
+               s = runtime·MHeap_AllocStack(&runtime·mheap, StackCacheSize >> PageShift);
+               if(s == nil)
+                       runtime·throw("out of memory");
++#ifdef GOOS_openbsd
++              runtime·sysMarkStack((void *)(s->start << PageShift), s->npages << PageShift);
++#endif
+               if(s->ref != 0)
+                       runtime·throw("bad ref");
+               if(s->freelist != nil)
+@@ -246,6 +249,9 @@ runtime·stackalloc(uint32 n)
+               s = runtime·MHeap_AllocStack(&runtime·mheap, ROUND(n, PageSize) >> PageShift);
+               if(s == nil)
+                       runtime·throw("out of memory");
++#ifdef GOOS_openbsd
++              runtime·sysMarkStack((void *)(s->start << PageShift), s->npages << PageShift);
++#endif
+               v = (byte*)(s->start<<PageShift);
+       }
+       



Home | Main Index | Thread Index | Old Index