From cb8f7357867a2a5d0bd742ceeb77bce9ad5f435c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Jan 2020 21:10:11 -0500 Subject: all: remove Linux 2.4 vs 2.6 detection Linux 2.4 is dead. (The libthread code hasn't worked for Linux 2.4 for a long time.) --- INSTALL | 23 +++-------------------- bin/9c | 14 +++----------- bin/9l | 17 ++++++----------- include/u.h | 6 ++---- lib/linux-isnptl.c | 16 ---------------- man/man1/9c.1 | 12 +++++------- man/man1/install.1 | 23 ++++++----------------- src/libthread/README.Linux | 40 ---------------------------------------- src/libthread/sysofiles.sh | 7 +++---- 9 files changed, 28 insertions(+), 130 deletions(-) delete mode 100644 lib/linux-isnptl.c delete mode 100644 src/libthread/README.Linux diff --git a/INSTALL b/INSTALL index 0291e713..11d35005 100755 --- a/INSTALL +++ b/INSTALL @@ -66,23 +66,6 @@ DragonFly|*BSD) esac ( -if [ `uname` = Linux ]; then - # On Linux, we use the kernel version to decide whether - # to use pthreads or not. On 2.6 versions that aren't - # linking with NPTL by default, pretend to be an older kernel. - echo "* Running on Linux: checking for NPTL..." - gcc lib/linux-isnptl.c -lpthread - if ./a.out >/dev/null - then - echo " NPTL found." - echo "SYSVERSION=2.6.x" >>$PLAN9/config - else - echo " NPTL not found." - echo "SYSVERSION=2.4.x" >>$PLAN9/config - fi - rm -f ./a.out -fi - if [ `uname` = SunOS ]; then # On Solaris x86, uname -p cannot be trusted. echo "* Running on Solaris: checking architecture..." @@ -168,7 +151,7 @@ if $dobuild; then echo "* Error: mk failed to build." exit 1 fi - + echo "* Building everything (be patient)..." mk clean mk libs-nuke @@ -216,13 +199,13 @@ if $doinstall; then mk man ) fi - + if [ -x LOCAL.INSTALL ]; then echo "* Running local modifications..." echo cd `pwd`';' ./LOCAL.INSTALL ./LOCAL.INSTALL fi - + echo "* Done. " echo " " echo "* Add these to your profile environment." diff --git a/bin/9c b/bin/9c index 20919e9a..b07d0149 100755 --- a/bin/9c +++ b/bin/9c @@ -93,28 +93,20 @@ case "$tag" in useclang cflags="$ngflags -g3 -m32" ;; -*Darwin*) usegcc +*Darwin*) usegcc cflags="$ngflags -g3 -no-cpp-precomp -m32" ;; *HP-UX*) cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;; -*Linux*) usegcc +*Linux*) usegcc case "${CC9:-gcc}" in tcc) cc=tcc cflags="-c -g" ;; esac - case "${SYSVERSION:-`uname -r`}" in - 2.4.*) - cflags="$cflags -D__Linux24__" - ;; - 2.6.*) - cflags="$cflags -D__Linux26__" - ;; - esac ;; *OSF1*) cc=${CC9:-cc}; cflags="-g -O -c" ;; *SunOS*-cc) cc=cc; - cflags="-mt -g -O -c -xCC -D__sun__" + cflags="-mt -g -O -c -xCC -D__sun__" u=`uname` v=`uname -r` s=`echo $u$v | tr '. ' '__'` diff --git a/bin/9l b/bin/9l index 8af27154..a10aab72 100755 --- a/bin/9l +++ b/bin/9l @@ -25,12 +25,7 @@ case "$tag" in *Linux*) ld=${CC9:-gcc} userpath=true - extralibs="$extralibs -lutil -lresolv" - case "${SYSVERSION:-`uname -r`}" in - 2.6.* | [3-9].* | [1-9][0-9].*) - extralibs="$extralibs -lpthread" - ;; - esac + extralibs="$extralibs -lutil -lresolv -lpthread" ;; *Darwin*x86_64*) ld="${CC9:-gcc} -m64" @@ -41,7 +36,7 @@ case "$tag" in *SunOS*) ld="${CC9:-cc} -g" extralibs="$extralibs -lrt -lpthread -lsocket -lnsl" - # Record paths to shared libraries to avoid needing LD_LIBRARY_PATH + # Record paths to shared libraries to avoid needing LD_LIBRARY_PATH for i in "$libsl $@" do case "$i" in @@ -106,7 +101,7 @@ then lpaths="$lpaths $l" esac done - + if $verbose then echo "ofiles $ofiles" @@ -309,7 +304,7 @@ then frameworks="" for i in $autoframeworks - do + do frameworks="-framework $i $frameworks" done fi @@ -335,8 +330,8 @@ fi xtmp="${TMPDIR-/tmp}/9l.$$.$USER.out" xxout() { - sed 's/.*: In function `[^:]*: *//' $xtmp | egrep . | - egrep -v 'is (often|almost always) misused|is dangerous, better use|text-based stub' + sed 's/.*: In function `[^:]*: *//' $xtmp | egrep . | + egrep -v 'is (often|almost always) misused|is dangerous, better use|text-based stub' rm -f $xtmp } diff --git a/include/u.h b/include/u.h index 8a715b1e..3bea890e 100644 --- a/include/u.h +++ b/include/u.h @@ -66,10 +66,8 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)]; #if defined(__linux__) # include -# if defined(__Linux26__) -# include -# define PLAN9PORT_USING_PTHREADS 1 -# endif +# include +# define PLAN9PORT_USING_PTHREADS 1 # if defined(__USE_MISC) # undef _NEEDUSHORT # undef _NEEDUINT diff --git a/lib/linux-isnptl.c b/lib/linux-isnptl.c deleted file mode 100644 index e4c23c63..00000000 --- a/lib/linux-isnptl.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include -#include - -int -main(void) -{ - ulong x; - - x = (ulong)pthread_self(); - printf("%lx\n", x); - if(x < 1024*1024) - exit(1); /* NOT NPTL */ - exit(0); -} diff --git a/man/man1/9c.1 b/man/man1/9c.1 index fb04a296..8d24d67d 100644 --- a/man/man1/9c.1 +++ b/man/man1/9c.1 @@ -79,9 +79,7 @@ to the include path. .I 9c also defines .B __sun__ -on SunOS systems and -.B __Linux26__ -on Linux systems with 2.6-series kernels. +on SunOS systems. .PP .I 9a assembles the named files into object files for the current system. @@ -136,13 +134,13 @@ but always provides the following key characters: .TP .B d -Delete -.I files +Delete +.I files from the archive file. .TP .B r Replace -.I files +.I files in the archive file, or add them if missing. .TP .B t @@ -181,7 +179,7 @@ Normally will create a new archive when .I afile does not exist, and give a warning. -Option +Option .B c discards any old contents and suppresses the warning. .PD diff --git a/man/man1/install.1 b/man/man1/install.1 index be35bd35..8fcc9e41 100644 --- a/man/man1/install.1 +++ b/man/man1/install.1 @@ -32,7 +32,7 @@ rebuilds and installs everything, and then cleans up. .PP There are a few files in tree which have the root hard-coded in them. -After the build, +After the build, .I INSTALL edits these files to replace the string .B /usr/local/plan9 @@ -71,31 +71,20 @@ expectations of certain package management systems. .PP At the end of the installation, .I INSTALL -prints suggested settings for the environment variables +prints suggested settings for the environment variables .B $PLAN9 and .BR $PATH . .PP -Plan 9 from User Space uses different threading implementations on Linux 2.6 and -later kernels than on 2.4 and earlier; -and on FreeBSD 5 and later kernels than on FreeBSD 4 and earlier. -Running binaries from one class on another will not work. -.PP -Some Linux 2.6 systems (e.g., Gentoo) do not use the new NPTL pthread library -even though the kernel supports them. On these systems, plan9port must -fall back on the threading code intended for Linux 2.4. To accomplish this, .I INSTALL -checks whether the running system uses NPTL and sets -.B SYSVERSION -in -.B \*9/config -accordingly. +writes various autodetected settings to +.BR \*9/config . The file .B \*9/LOCAL.config is appended to .B config after this auto-detection and can be used to override the choices. -If +If .B LOCAL.config contains a line .B WSYSTYPE=nowsys @@ -110,7 +99,7 @@ On Ubuntu, it suffices to install xorg-dev. can safely be repeated to rebuild the system from scratch. .PP Once the system is built for the first time, -it can be maintained and rebuilt using +it can be maintained and rebuilt using .IR mk (1). To rebuild individual commands or libraries, run diff --git a/src/libthread/README.Linux b/src/libthread/README.Linux deleted file mode 100644 index 04c491a8..00000000 --- a/src/libthread/README.Linux +++ /dev/null @@ -1,40 +0,0 @@ -Thread support on Linux is confused by the recent thread local storage (TLS) -support that has been put into the ELF tool chain. The TLS libraries are -installed in /lib/tls on most Linux systems. - -We provide two different implementations of the os-dependent parts -of libthread for Linux. The first is intended for use on Linux 2.4 and earlier -kernels, which do not support TLS. It is in Linux.c and Linuxasm.c and -does not use the pthread interface. The second is intended for Linux 2.6 -and later kernels, which do support TLS. It is in pthread.c and uses the -standard pthread interface. It expects to be linked against the TLS-aware -thread library aka NPTL. - -If you use Linux.c and Linuxasm.c with TLS libraries, they do not -set up the TLS properly so you will get incorrect programs. -For example, there will only be one errno among all the procs -in your program instead of one per proc. The pthread NPTL -implementation is needed to use the TLS libraries properly. - -If you use pthread.c without TLS libraries (i.e., with the old Linux -pthread library known as LinuxThreads), then you will also get -incorrect programs, although more obviously so. The LinuxThreads -library assumes it can look at the stack pointer to distinguish between -threads, but libthread does its own stack management, breaking this -assumption. If you run a pthread-compiled program with the -LinuxThreads library, LinuxThreads itself will cause a segmentation -fault in __pthread_getspecific() the first time it is called from a -non-standard stack. - -So, it is important that you compile binaries that match your -system's choice of TLS vs. not-TLS libraries. The hard part is figuring -out which your system has chosen. Plan9port looks at the kernel -version you are running and assumes that on kernels that support -TLS (2.6+) you will be using TLS. - -Apparently Gentoo and maybe other distributions do not follow this rule. -They use non-TLS libraries even on kernels that can support TLS. -To accomodate them, you can add a line SYSVERSION=2.4 to $PLAN9/config -to force the build to think you are running an old kernel. -The INSTALL script sets up this file automatically on Linux systems. - diff --git a/src/libthread/sysofiles.sh b/src/libthread/sysofiles.sh index 30a4c338..fd60f131 100644 --- a/src/libthread/sysofiles.sh +++ b/src/libthread/sysofiles.sh @@ -2,12 +2,11 @@ test -f $PLAN9/config && . $PLAN9/config -tag="$OBJTYPE-$SYSNAME-${SYSVERSION:-`uname -r`}-${CC9:-cc}" -case "$tag" in -*-NetBSD-*) +case "$SYSNAME" in +NetBSD) echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o pthread.o stkmalloc.o ;; -*-OpenBSD-*) +OpenBSD) echo ${SYSNAME}-${OBJTYPE}-asm.o ${SYSNAME}-${OBJTYPE}.o pthread.o stkmmap.o ;; *) -- cgit v1.2.3