pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
plan9port: Add pull requests from upstream to fix build issues
Module Name: pkgsrc-wip
Committed By: Leonardo Taccari <leot%NetBSD.org@localhost>
Pushed By: leot
Date: Tue Jul 7 21:36:42 2020 +0200
Changeset: 674a0d81c9428d7b0b8d530c851f0e2b31fbf8f9
Modified Files:
plan9port/Makefile
plan9port/TODO
plan9port/distinfo
Added Files:
plan9port/patches/patch-include_u.h
plan9port/patches/patch-src_cmd_devdraw_mkwsysrules.sh
plan9port/patches/patch-src_libthread_NetBSD-386-asm.s
plan9port/patches/patch-src_libthread_NetBSD-power-asm.s
plan9port/patches/patch-src_libthread_NetBSD.c
plan9port/patches/patch-src_libthread_sysofiles.sh
Log Message:
plan9port: Add pull requests from upstream to fix build issues
Update TODO documenting that now a way to install it should be found.
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=674a0d81c9428d7b0b8d530c851f0e2b31fbf8f9
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
plan9port/Makefile | 7 +
plan9port/TODO | 4 +-
plan9port/distinfo | 6 +
plan9port/patches/patch-include_u.h | 19 +
.../patches/patch-src_cmd_devdraw_mkwsysrules.sh | 19 +
.../patches/patch-src_libthread_NetBSD-386-asm.s | 18 +
.../patches/patch-src_libthread_NetBSD-power-asm.s | 27 ++
plan9port/patches/patch-src_libthread_NetBSD.c | 442 +++++++++++++++++++++
plan9port/patches/patch-src_libthread_sysofiles.sh | 14 +
9 files changed, 553 insertions(+), 3 deletions(-)
diffs:
diff --git a/plan9port/Makefile b/plan9port/Makefile
index 44f1a43ba8..8af1aab64e 100644
--- a/plan9port/Makefile
+++ b/plan9port/Makefile
@@ -11,6 +11,13 @@ COMMENT= Plan 9 from User Space
LICENSE= lucent
USE_LANGUAGES= c c++
+USE_TOOLS+= bash:run perl
+
+REPLACE_BASH+= src/cmd/rc/checkparse
+
+REPLACE_PERL+= dist/addsrclinks
+REPLACE_PERL+= dist/fixurls
+REPLACE_PERL+= unix/man/fixurls
do-build:
cd ${WRKSRC} && ./INSTALL -b
diff --git a/plan9port/TODO b/plan9port/TODO
index 601a165747..4d1a1d7f5c 100644
--- a/plan9port/TODO
+++ b/plan9port/TODO
@@ -1,3 +1 @@
-On NetBSD/amd64 -current the build fails with:
-
- >>> mk: don't know how to make '.../pkgsrc/wip/plan9port/work/plan9port-95ab1308b410ad8547e38e47ec4a36f560dcece5/lib/libthread.a(NetBSD-x86_64-asm.o)' in .../pkgsrc/wip/plan9port/work/plan9port-95ab1308b410ad8547e38e47ec4a36f560dcece5/src/libthread
+Figure out how to handle the install phase.
diff --git a/plan9port/distinfo b/plan9port/distinfo
index 5a7764a7c3..ffa8113ed5 100644
--- a/plan9port/distinfo
+++ b/plan9port/distinfo
@@ -4,3 +4,9 @@ SHA1 (plan9port-20200622-95ab1308b410ad8547e38e47ec4a36f560dcece5.tar.gz) = af51
RMD160 (plan9port-20200622-95ab1308b410ad8547e38e47ec4a36f560dcece5.tar.gz) = dcd35a7564d1c0569383a6d9782a6c64de10ccac
SHA512 (plan9port-20200622-95ab1308b410ad8547e38e47ec4a36f560dcece5.tar.gz) = e3e2f66c854304702f10568a3ae8990f62b6b66872f0bb6b9e3f629ff5616e82ce2c88331ec58f27d1c9cf9fda6c7d0cb072e7a746ed0ce94dc600918efda964
Size (plan9port-20200622-95ab1308b410ad8547e38e47ec4a36f560dcece5.tar.gz) = 23445330 bytes
+SHA1 (patch-include_u.h) = d8681e7c663f9dd6da46d0af2eb33a8e1b014fbd
+SHA1 (patch-src_cmd_devdraw_mkwsysrules.sh) = 7418cfbedafa74145c4c3395fe11b2bb3b6b50ef
+SHA1 (patch-src_libthread_NetBSD-386-asm.s) = 474ee6eaf11115b31b1abf4e1536eceab4b5e0c7
+SHA1 (patch-src_libthread_NetBSD-power-asm.s) = 516705bd9d87e4c4010b7eff2add38a9ec1abbda
+SHA1 (patch-src_libthread_NetBSD.c) = 7ffd4bd3da4cc50bb74210bffd10288b3831ac06
+SHA1 (patch-src_libthread_sysofiles.sh) = 8c13a3185a0b03aede29dc3eefdd1ebe4ea79073
diff --git a/plan9port/patches/patch-include_u.h b/plan9port/patches/patch-include_u.h
new file mode 100644
index 0000000000..6f3f30a5b9
--- /dev/null
+++ b/plan9port/patches/patch-include_u.h
@@ -0,0 +1,19 @@
+$NetBSD$
+
+Use pthreads on NetBSD.
+
+From upstream pull request #355:
+
+ <https://github.com/9fans/plan9port/pull/355>
+
+--- include/u.h.orig 2020-06-22 15:22:27.000000000 +0000
++++ include/u.h
+@@ -108,6 +108,8 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf
+ #elif defined(__NetBSD__)
+ # include <sched.h>
+ # include <sys/types.h>
++# include <pthread.h>
++# define PLAN9PORT_USING_PTHREADS 1
+ # undef _NEEDUSHORT
+ # undef _NEEDUINT
+ # undef _NEEDULONG
diff --git a/plan9port/patches/patch-src_cmd_devdraw_mkwsysrules.sh b/plan9port/patches/patch-src_cmd_devdraw_mkwsysrules.sh
new file mode 100644
index 0000000000..f8eb90b9ab
--- /dev/null
+++ b/plan9port/patches/patch-src_cmd_devdraw_mkwsysrules.sh
@@ -0,0 +1,19 @@
+$NetBSD$
+
+Also look in /usr/X11R7.
+
+From upstream pull request #362:
+
+ <https://github.com/9fans/plan9port/pull/362>
+
+--- src/cmd/devdraw/mkwsysrules.sh.orig 2020-06-22 15:22:27.000000000 +0000
++++ src/cmd/devdraw/mkwsysrules.sh
+@@ -7,6 +7,8 @@ if [ "x$X11" = "x" ]; then
+ X11=/usr/X11R6
+ elif [ -d /usr/local/X11R6 ]; then
+ X11=/usr/local/X11R6
++ elif [ -d /usr/X11R7 ]; then
++ X11=/usr/X11R7
+ elif [ -d /usr/X ]; then
+ X11=/usr/X
+ elif [ -d /usr/openwin ]; then # for Sun
diff --git a/plan9port/patches/patch-src_libthread_NetBSD-386-asm.s b/plan9port/patches/patch-src_libthread_NetBSD-386-asm.s
new file mode 100644
index 0000000000..2e6e2773a0
--- /dev/null
+++ b/plan9port/patches/patch-src_libthread_NetBSD-386-asm.s
@@ -0,0 +1,18 @@
+$NetBSD$
+
+Use pthreads on NetBSD.
+
+From upstream pull request #355:
+
+ <https://github.com/9fans/plan9port/pull/355>
+
+--- src/libthread/NetBSD-386-asm.s.orig 2020-06-22 15:22:27.000000000 +0000
++++ src/libthread/NetBSD-386-asm.s
+@@ -1,7 +0,0 @@
+-.globl _tas
+-_tas:
+- movl $0xCAFEBABE, %eax
+- movl 4(%esp), %ecx
+- xchgl %eax, 0(%ecx)
+- ret
+-
diff --git a/plan9port/patches/patch-src_libthread_NetBSD-power-asm.s b/plan9port/patches/patch-src_libthread_NetBSD-power-asm.s
new file mode 100644
index 0000000000..eda7d01a9c
--- /dev/null
+++ b/plan9port/patches/patch-src_libthread_NetBSD-power-asm.s
@@ -0,0 +1,27 @@
+$NetBSD$
+
+Use pthreads on NetBSD.
+
+From upstream pull request #355:
+
+ <https://github.com/9fans/plan9port/pull/355>
+
+--- src/libthread/NetBSD-power-asm.s.orig 2020-06-22 15:22:27.000000000 +0000
++++ src/libthread/NetBSD-power-asm.s
+@@ -1,16 +0,0 @@
+- .globl _tas
+-_tas:
+- li %r0, 0
+- mr %r4, %r3
+- lis %r5, 0xcafe
+- ori %r5, %r5, 0xbabe
+-1:
+- lwarx %r3, %r0, %r4
+- cmpwi %r3, 0
+- bne 2f
+- stwcx. %r5, %r0, %r4
+- bne- 1b
+-2:
+- sync
+- blr
+-
diff --git a/plan9port/patches/patch-src_libthread_NetBSD.c b/plan9port/patches/patch-src_libthread_NetBSD.c
new file mode 100644
index 0000000000..8b0efb3113
--- /dev/null
+++ b/plan9port/patches/patch-src_libthread_NetBSD.c
@@ -0,0 +1,442 @@
+$NetBSD$
+
+--- src/libthread/NetBSD.c.orig 2020-06-22 15:22:27.000000000 +0000
++++ src/libthread/NetBSD.c
+@@ -1,437 +0,0 @@
+-#include "threadimpl.h"
+-
+-#undef exits
+-#undef _exits
+-
+-static int
+-timefmt(Fmt *fmt)
+-{
+- static char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+- vlong ns;
+- Tm tm;
+- ns = nsec();
+- tm = *localtime(time(0));
+- return fmtprint(fmt, "%s %2d %02d:%02d:%02d.%03d",
+- mon[tm.mon], tm.mday, tm.hour, tm.min, tm.sec,
+- (int)(ns%1000000000)/1000000);
+-}
+-
+-/*
+- * spin locks
+- */
+-extern int _tas(int*);
+-
+-void
+-_threadunlock(Lock *l, ulong pc)
+-{
+- USED(pc);
+-
+- l->held = 0;
+-}
+-
+-int
+-_threadlock(Lock *l, int block, ulong pc)
+-{
+- int i;
+-static int first=1;
+-if(first) {first=0; fmtinstall('\001', timefmt);}
+-
+- USED(pc);
+-
+- /* once fast */
+- if(!_tas(&l->held))
+- return 1;
+- if(!block)
+- return 0;
+-
+- /* a thousand times pretty fast */
+- for(i=0; i<1000; i++){
+- if(!_tas(&l->held))
+- return 1;
+- sched_yield();
+- }
+- /* now increasingly slow */
+- for(i=0; i<10; i++){
+- if(!_tas(&l->held))
+- return 1;
+- usleep(1);
+- }
+-fprint(2, "%\001 %s: lock loop1 %p from %lux\n", argv0, l, pc);
+- for(i=0; i<10; i++){
+- if(!_tas(&l->held))
+- return 1;
+- usleep(10);
+- }
+-fprint(2, "%\001 %s: lock loop2 %p from %lux\n", argv0, l, pc);
+- for(i=0; i<10; i++){
+- if(!_tas(&l->held))
+- return 1;
+- usleep(100);
+- }
+-fprint(2, "%\001 %s: lock loop3 %p from %lux\n", argv0, l, pc);
+- for(i=0; i<10; i++){
+- if(!_tas(&l->held))
+- return 1;
+- usleep(1000);
+- }
+-fprint(2, "%\001 %s: lock loop4 %p from %lux\n", argv0, l, pc);
+- for(i=0; i<10; i++){
+- if(!_tas(&l->held))
+- return 1;
+- usleep(10*1000);
+- }
+-fprint(2, "%\001 %s: lock loop5 %p from %lux\n", argv0, l, pc);
+- for(i=0; i<1000; i++){
+- if(!_tas(&l->held))
+- return 1;
+- usleep(100*1000);
+- }
+-fprint(2, "%\001 %s: lock loop6 %p from %lux\n", argv0, l, pc);
+- /* take your time */
+- while(_tas(&l->held))
+- usleep(1000*1000);
+- return 1;
+-}
+-
+-/*
+- * sleep and wakeup
+- */
+-static void
+-ign(int x)
+-{
+- USED(x);
+-}
+-
+-static void /*__attribute__((constructor))*/
+-ignusr1(int restart)
+-{
+- struct sigaction sa;
+-
+- memset(&sa, 0, sizeof sa);
+- sa.sa_handler = ign;
+- sigemptyset(&sa.sa_mask);
+- sigaddset(&sa.sa_mask, SIGUSR1);
+- if(restart)
+- sa.sa_flags = SA_RESTART;
+- sigaction(SIGUSR1, &sa, nil);
+-}
+-
+-void
+-_procsleep(_Procrendez *r)
+-{
+- sigset_t mask;
+-
+- /*
+- * Go to sleep.
+- *
+- * Block USR1, set the handler to interrupt system calls,
+- * unlock the vouslock so our waker can wake us,
+- * and then suspend.
+- */
+-again:
+- r->asleep = 1;
+- r->pid = getpid();
+-
+- sigprocmask(SIG_SETMASK, nil, &mask);
+- sigaddset(&mask, SIGUSR1);
+- sigprocmask(SIG_SETMASK, &mask, nil);
+- ignusr1(0);
+- unlock(r->l);
+- sigdelset(&mask, SIGUSR1);
+- sigsuspend(&mask);
+-
+- /*
+- * We're awake. Make USR1 not interrupt system calls.
+- */
+- lock(r->l);
+- ignusr1(1);
+- if(r->asleep && r->pid == getpid()){
+- /* Didn't really wake up - signal from something else */
+- goto again;
+- }
+-}
+-
+-void
+-_procwakeupandunlock(_Procrendez *r)
+-{
+- int pid;
+-
+- pid = 0;
+- if(r->asleep){
+- r->asleep = 0;
+- assert(r->pid >= 1);
+- pid = r->pid;
+- }
+- assert(r->l);
+- unlock(r->l);
+- if(pid)
+- kill(pid, SIGUSR1);
+-}
+-
+-/*
+- * process creation and exit
+- */
+-typedef struct Stackfree Stackfree;
+-struct Stackfree
+-{
+- Stackfree *next;
+- int pid;
+- int pid1;
+-};
+-static Lock stacklock;
+-static Stackfree *stackfree;
+-
+-static void
+-delayfreestack(uchar *stk, int pid, int pid1)
+-{
+- Stackfree *sf;
+-
+- sf = (Stackfree*)stk;
+- sf->pid = pid;
+- sf->pid1 = pid1;
+- lock(&stacklock);
+- sf->next = stackfree;
+- stackfree = sf;
+- unlock(&stacklock);
+-}
+-
+-static void
+-dofreestacks(void)
+-{
+- Stackfree *sf, *last, *next;
+-
+- if(stackfree==nil || !canlock(&stacklock))
+- return;
+-
+- for(last=nil,sf=stackfree; sf; last=sf,sf=next){
+- next = sf->next;
+- if(sf->pid >= 1 && kill(sf->pid, 0) < 0 && errno == ESRCH)
+- if(sf->pid1 >= 1 && kill(sf->pid1, 0) < 0 && errno == ESRCH){
+- free(sf);
+- if(last)
+- last->next = next;
+- else
+- stackfree = next;
+- sf = last;
+- }
+- }
+- unlock(&stacklock);
+-}
+-
+-static int
+-startprocfn(void *v)
+-{
+- void **a;
+- uchar *stk;
+- void (*fn)(void*);
+- Proc *p;
+- int pid0, pid1;
+-
+- a = (void**)v;
+- fn = a[0];
+- p = a[1];
+- stk = a[2];
+- pid0 = (int)a[4];
+- pid1 = getpid();
+- free(a);
+- p->osprocid = pid1;
+-
+- (*fn)(p);
+-
+- delayfreestack(stk, pid0, pid1);
+- _exit(0);
+- return 0;
+-}
+-
+-/*
+- * indirect through here so that parent need not wait for child zombie
+- *
+- * slight race - if child exits and then another process starts before we
+- * manage to exit, we'll be running on a freed stack.
+- */
+-static int
+-trampnowait(void *v)
+-{
+- void **a;
+- int *kidpid;
+-
+- a = (void*)v;
+- kidpid = a[3];
+- a[4] = (void*)getpid();
+- *kidpid = clone(startprocfn, a[2]+65536-512, CLONE_VM|CLONE_FILES, a);
+- _exit(0);
+- return 0;
+-}
+-
+-void
+-_procstart(Proc *p, void (*fn)(Proc*))
+-{
+- void **a;
+- uchar *stk;
+- int pid, kidpid, status;
+-
+- dofreestacks();
+- a = malloc(5*sizeof a[0]);
+- if(a == nil)
+- sysfatal("_procstart malloc: %r");
+- stk = malloc(65536);
+- if(stk == nil)
+- sysfatal("_procstart malloc stack: %r");
+-
+- a[0] = fn;
+- a[1] = p;
+- a[2] = stk;
+- a[3] = &kidpid;
+- kidpid = -1;
+-
+- pid = clone(trampnowait, stk+65536-16, CLONE_VM|CLONE_FILES, a);
+- if(pid > 0)
+- if(wait4(pid, &status, __WALL, 0) < 0)
+- fprint(2, "ffork wait4: %r\n");
+- if(pid < 0 || kidpid < 0){
+- fprint(2, "_procstart clone: %r\n");
+- abort();
+- }
+-}
+-
+-static char *threadexitsmsg;
+-void
+-sigusr2handler(int s)
+-{
+-/* fprint(2, "%d usr2 %d\n", time(0), getpid()); */
+- if(threadexitsmsg)
+- _exits(threadexitsmsg);
+-}
+-
+-void
+-threadexitsall(char *msg)
+-{
+- static int pid[1024];
+- int i, npid, mypid;
+- Proc *p;
+-
+- if(msg == nil)
+- msg = "";
+-
+- /*
+- * Only one guy, ever, gets to run this.
+- * If two guys do it, inevitably they end up
+- * tripping over each other in the underlying
+- * C library exit() implementation, which is
+- * trying to run the atexit handlers and apparently
+- * not thread safe. This has been observed on
+- * both Linux and OpenBSD. Sigh.
+- */
+- {
+- static Lock onelock;
+- if(!canlock(&onelock))
+- _exits(threadexitsmsg);
+- threadexitsmsg = msg;
+- }
+-
+- mypid = getpid();
+- lock(&_threadprocslock);
+- npid = 0;
+- for(p=_threadprocs; p; p=p->next)
+- if(p->osprocid != mypid && p->osprocid >= 1)
+- pid[npid++] = p->osprocid;
+- for(i=0; i<npid; i++)
+- kill(pid[i], SIGUSR2);
+- unlock(&_threadprocslock);
+- exits(msg);
+-}
+-
+-/*
+- * per-process data, indexed by pid
+- *
+- * could use modify_ldt and a segment register
+- * to avoid the many calls to getpid(), but i don't
+- * care -- this is compatibility code. linux 2.6 with
+- * nptl is a good enough pthreads to avoid this whole file.
+- */
+-typedef struct Perproc Perproc;
+-struct Perproc
+-{
+- int pid;
+- Proc *proc;
+-};
+-
+-static Lock perlock;
+-static Perproc perproc[1024];
+-#define P ((Proc*)-1)
+-
+-static Perproc*
+-myperproc(void)
+-{
+- int i, pid, h;
+- Perproc *p;
+-
+- pid = getpid();
+- h = pid%nelem(perproc);
+- for(i=0; i<nelem(perproc); i++){
+- p = &perproc[(i+h)%nelem(perproc)];
+- if(p->pid == pid)
+- return p;
+- if(p->pid == 0){
+- print("found 0 at %d (h=%d)\n", (i+h)%nelem(perproc), h);
+- break;
+- }
+- }
+- fprint(2, "myperproc %d (%s): cannot find self\n", pid, argv0);
+- abort();
+- return nil;
+-}
+-
+-static Perproc*
+-newperproc(void)
+-{
+- int i, pid, h;
+- Perproc *p;
+-
+- lock(&perlock);
+- pid = getpid();
+- h = pid%nelem(perproc);
+- for(i=0; i<nelem(perproc); i++){
+- p = &perproc[(i+h)%nelem(perproc)];
+- if(p->pid == pid || p->pid == -1 || p->pid == 0){
+- p->pid = pid;
+- unlock(&perlock);
+- return p;
+- }
+- }
+- fprint(2, "newperproc %d: out of procs\n", pid);
+- abort();
+- return nil;
+-}
+-
+-Proc*
+-_threadproc(void)
+-{
+- return myperproc()->proc;
+-}
+-
+-void
+-_threadsetproc(Proc *p)
+-{
+- Perproc *pp;
+-
+- if(p)
+- p->osprocid = getpid();
+- pp = newperproc();
+- pp->proc = p;
+- if(p == nil)
+- pp->pid = -1;
+-}
+-
+-void
+-_pthreadinit(void)
+-{
+- signal(SIGUSR2, sigusr2handler);
+-}
+-
+-void
+-_threadpexit(void)
+-{
+- _exit(0);
+-}
diff --git a/plan9port/patches/patch-src_libthread_sysofiles.sh b/plan9port/patches/patch-src_libthread_sysofiles.sh
new file mode 100644
index 0000000000..0c095e8c1f
--- /dev/null
+++ b/plan9port/patches/patch-src_libthread_sysofiles.sh
@@ -0,0 +1,14 @@
+$NetBSD$
+
+--- src/libthread/sysofiles.sh.orig 2020-06-22 15:22:27.000000000 +0000
++++ src/libthread/sysofiles.sh
+@@ -3,9 +3,6 @@
+ test -f $PLAN9/config && . $PLAN9/config
+
+ case "$SYSNAME" in
+-NetBSD)
+- echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o stkmalloc.o
+- ;;
+ OpenBSD)
+ echo pthread.o stkmmap.o
+ ;;
Home |
Main Index |
Thread Index |
Old Index