9fans / plan9port

Plan 9 from User Space
https://9fans.github.io/plan9port/
Other
1.64k stars 326 forks source link

libthread: use pthreads on NetBSD #355

Closed rsc closed 3 years ago

rsc commented 4 years ago

Would be nice if this worked. No idea whether it does. If anyone wants to test it and report back, that would be great. See also ac8042d and 23a2368.

ghost commented 4 years ago

I have NetBSD installed in one partition so I booted into it to give this a try. It's a 64-bit version:

# uname -a
NetBSD hope 8.1 NetBSD 8.1 (GENERIC) #0: Fri May 31 08:43:59 UTC 2019  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64

This branch compiles with some warnings:

# ./INSTALL
+ Mailing list: https://groups.google.com/group/plan9port-dev
+ Issue tracker: https://github.com/9fans/plan9port/issues/
+ Submitting changes: https://github.com/9fans/plan9port/pulls

* Resetting /config
* Running on NetBSD, adjusting linker flags
* Compiler version:
        gcc version 5.5.0 (nb3 20180905) 
* Building everything (be patient)...
>>> cd /usr/local/plan9/src/libmach; mk all               
9c -pthread -I. NetBSD.c
FreeBSD.c:111:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     *(u32int*)buf = u;
     ^
FreeBSD.c:122:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     *(u32int*)buf = u;
     ^
FreeBSD.c:124:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     u = *(u32int*)buf;
     ^
cc1: warning: unrecognized command line option '-Wno-format-truncation'
cc1: warning: unrecognized command line option '-Wno-stringop-overflow'
cc1: warning: unrecognized command line option '-Wno-stringop-truncation'
cc1: warning: unrecognized command line option '-Wno-misleading-indentation'
>>> cd /usr/local/plan9/src/libthread; mk all 
9c -o pthread.o -pthread -I. pthread.c
pthread.c:151:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   if(*(ulong*)(void*)&id < 1024*1024)
   ^
cc1: warning: unrecognized command line option '-Wno-format-truncation'
cc1: warning: unrecognized command line option '-Wno-stringop-overflow'
cc1: warning: unrecognized command line option '-Wno-stringop-truncation'
cc1: warning: unrecognized command line option '-Wno-misleading-indentation'
* Installing everything in /usr/local/plan9/bin...      
* Cleaning up...                                       
* Renaming hard-coded /usr/local/plan9 paths...           
* Building web manual...
* Done.                          

* Add these to your profile environment.
        PLAN9=/usr/local/plan9 export PLAN9
        PATH=$PATH:$PLAN9/bin export PATH

Trying to start any graphical programs gives:

usage: devdraw (don't run  directly)
acme: can't open display: muxrpc: unexpected eof

Tried starting auxstats; it hangs. The 9p program seems to work:

$ 9p -a 9front.org ls
9front
extra
fqa
hardware
iso
lists
pkg
sites
sevan commented 4 years ago

Without this patch, on NetBSD 9.99.46, the build breaks with >>> mk: don't know how to make '/home/sme/sandbox/plan9port/lib/libthread.a(NetBSD-x86_64-asm.o)' in /home/sme/sandbox/plan9port/src/libthread mk: for i in ... : exit status=exit(1)

With this patch on the same NetBSD build, it succeeds but warns >>> cd /home/sme/sandbox/plan9port/src/libthread; mk all 9c -o pthread.o -pthread -I. pthread.c pthread.c:151:7: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] if(*(ulong*)(void*)&id < 1024*1024)

Same results as @nicolagi above when running acme, auxstats, 9p on NetBSD 9.99.46

sevan commented 4 years ago

With pull request #362 applied, acme now working on NetBSD as well.

sevan commented 4 years ago

Tested building and running acme on NetBSD/macppc without issue

ghost commented 4 years ago

Hi Sevan, thanks for your fix, I confirmed it works in NetBSD 8.1 amd64 as well. 9term fails for me and I added this https://gist.github.com/nicolagi/341cf1fcd06be91a41fdccfbfec3f80e to fix that, shamelessly copying from FreeBSD.c and fixing the include.

sevan commented 4 years ago

@nicolagi great, that works for me as well. Tested on 9.99.50 amd64. Raise a pull request?

sevan commented 4 years ago

@rsc could these pull requests be merged?