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.)
This commit is contained in:
Russ Cox 2020-01-19 21:10:11 -05:00
parent 8d82ccefd2
commit cb8f735786
9 changed files with 28 additions and 130 deletions

23
INSTALL
View file

@ -66,23 +66,6 @@ DragonFly|*BSD)
esac 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 if [ `uname` = SunOS ]; then
# On Solaris x86, uname -p cannot be trusted. # On Solaris x86, uname -p cannot be trusted.
echo "* Running on Solaris: checking architecture..." echo "* Running on Solaris: checking architecture..."
@ -168,7 +151,7 @@ if $dobuild; then
echo "* Error: mk failed to build." echo "* Error: mk failed to build."
exit 1 exit 1
fi fi
echo "* Building everything (be patient)..." echo "* Building everything (be patient)..."
mk clean mk clean
mk libs-nuke mk libs-nuke
@ -216,13 +199,13 @@ if $doinstall; then
mk man mk man
) )
fi fi
if [ -x LOCAL.INSTALL ]; then if [ -x LOCAL.INSTALL ]; then
echo "* Running local modifications..." echo "* Running local modifications..."
echo cd `pwd`';' ./LOCAL.INSTALL echo cd `pwd`';' ./LOCAL.INSTALL
./LOCAL.INSTALL ./LOCAL.INSTALL
fi fi
echo "* Done. " echo "* Done. "
echo " " echo " "
echo "* Add these to your profile environment." echo "* Add these to your profile environment."

14
bin/9c
View file

@ -93,28 +93,20 @@ case "$tag" in
useclang useclang
cflags="$ngflags -g3 -m32" cflags="$ngflags -g3 -m32"
;; ;;
*Darwin*) usegcc *Darwin*) usegcc
cflags="$ngflags -g3 -no-cpp-precomp -m32" ;; cflags="$ngflags -g3 -no-cpp-precomp -m32" ;;
*HP-UX*) cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;; *HP-UX*) cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;;
*Linux*) usegcc *Linux*) usegcc
case "${CC9:-gcc}" in case "${CC9:-gcc}" in
tcc) tcc)
cc=tcc cc=tcc
cflags="-c -g" cflags="-c -g"
;; ;;
esac 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" ;; *OSF1*) cc=${CC9:-cc}; cflags="-g -O -c" ;;
*SunOS*-cc) cc=cc; *SunOS*-cc) cc=cc;
cflags="-mt -g -O -c -xCC -D__sun__" cflags="-mt -g -O -c -xCC -D__sun__"
u=`uname` u=`uname`
v=`uname -r` v=`uname -r`
s=`echo $u$v | tr '. ' '__'` s=`echo $u$v | tr '. ' '__'`

17
bin/9l
View file

@ -25,12 +25,7 @@ case "$tag" in
*Linux*) *Linux*)
ld=${CC9:-gcc} ld=${CC9:-gcc}
userpath=true userpath=true
extralibs="$extralibs -lutil -lresolv" extralibs="$extralibs -lutil -lresolv -lpthread"
case "${SYSVERSION:-`uname -r`}" in
2.6.* | [3-9].* | [1-9][0-9].*)
extralibs="$extralibs -lpthread"
;;
esac
;; ;;
*Darwin*x86_64*) *Darwin*x86_64*)
ld="${CC9:-gcc} -m64" ld="${CC9:-gcc} -m64"
@ -41,7 +36,7 @@ case "$tag" in
*SunOS*) *SunOS*)
ld="${CC9:-cc} -g" ld="${CC9:-cc} -g"
extralibs="$extralibs -lrt -lpthread -lsocket -lnsl" 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 $@" for i in "$libsl $@"
do do
case "$i" in case "$i" in
@ -106,7 +101,7 @@ then
lpaths="$lpaths $l" lpaths="$lpaths $l"
esac esac
done done
if $verbose if $verbose
then then
echo "ofiles $ofiles" echo "ofiles $ofiles"
@ -309,7 +304,7 @@ then
frameworks="" frameworks=""
for i in $autoframeworks for i in $autoframeworks
do do
frameworks="-framework $i $frameworks" frameworks="-framework $i $frameworks"
done done
fi fi
@ -335,8 +330,8 @@ fi
xtmp="${TMPDIR-/tmp}/9l.$$.$USER.out" xtmp="${TMPDIR-/tmp}/9l.$$.$USER.out"
xxout() { xxout() {
sed 's/.*: In function `[^:]*: *//' $xtmp | egrep . | sed 's/.*: In function `[^:]*: *//' $xtmp | egrep . |
egrep -v 'is (often|almost always) misused|is dangerous, better use|text-based stub' egrep -v 'is (often|almost always) misused|is dangerous, better use|text-based stub'
rm -f $xtmp rm -f $xtmp
} }

View file

@ -66,10 +66,8 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
#if defined(__linux__) #if defined(__linux__)
# include <sys/types.h> # include <sys/types.h>
# if defined(__Linux26__) # include <pthread.h>
# include <pthread.h> # define PLAN9PORT_USING_PTHREADS 1
# define PLAN9PORT_USING_PTHREADS 1
# endif
# if defined(__USE_MISC) # if defined(__USE_MISC)
# undef _NEEDUSHORT # undef _NEEDUSHORT
# undef _NEEDUINT # undef _NEEDUINT

View file

@ -1,16 +0,0 @@
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int
main(void)
{
ulong x;
x = (ulong)pthread_self();
printf("%lx\n", x);
if(x < 1024*1024)
exit(1); /* NOT NPTL */
exit(0);
}

View file

@ -79,9 +79,7 @@ to the include path.
.I 9c .I 9c
also defines also defines
.B __sun__ .B __sun__
on SunOS systems and on SunOS systems.
.B __Linux26__
on Linux systems with 2.6-series kernels.
.PP .PP
.I 9a .I 9a
assembles the named files into object files for the current system. assembles the named files into object files for the current system.
@ -136,13 +134,13 @@ but
always provides the following key characters: always provides the following key characters:
.TP .TP
.B d .B d
Delete Delete
.I files .I files
from the archive file. from the archive file.
.TP .TP
.B r .B r
Replace Replace
.I files .I files
in the archive file, or add them if missing. in the archive file, or add them if missing.
.TP .TP
.B t .B t
@ -181,7 +179,7 @@ Normally
will create a new archive when will create a new archive when
.I afile .I afile
does not exist, and give a warning. does not exist, and give a warning.
Option Option
.B c .B c
discards any old contents and suppresses the warning. discards any old contents and suppresses the warning.
.PD .PD

View file

@ -32,7 +32,7 @@ rebuilds and installs everything, and then cleans up.
.PP .PP
There are a few files in tree which have the root There are a few files in tree which have the root
hard-coded in them. hard-coded in them.
After the build, After the build,
.I INSTALL .I INSTALL
edits these files to replace the string edits these files to replace the string
.B /usr/local/plan9 .B /usr/local/plan9
@ -71,31 +71,20 @@ expectations of certain package management systems.
.PP .PP
At the end of the installation, At the end of the installation,
.I INSTALL .I INSTALL
prints suggested settings for the environment variables prints suggested settings for the environment variables
.B $PLAN9 .B $PLAN9
and and
.BR $PATH . .BR $PATH .
.PP .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 .I INSTALL
checks whether the running system uses NPTL and sets writes various autodetected settings to
.B SYSVERSION .BR \*9/config .
in
.B \*9/config
accordingly.
The file The file
.B \*9/LOCAL.config .B \*9/LOCAL.config
is appended to is appended to
.B config .B config
after this auto-detection and can be used to override the choices. after this auto-detection and can be used to override the choices.
If If
.B LOCAL.config .B LOCAL.config
contains a line contains a line
.B WSYSTYPE=nowsys .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. can safely be repeated to rebuild the system from scratch.
.PP .PP
Once the system is built for the first time, 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). .IR mk (1).
To rebuild individual commands or libraries, To rebuild individual commands or libraries,
run run

View file

@ -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.

View file

@ -2,12 +2,11 @@
test -f $PLAN9/config && . $PLAN9/config test -f $PLAN9/config && . $PLAN9/config
tag="$OBJTYPE-$SYSNAME-${SYSVERSION:-`uname -r`}-${CC9:-cc}" case "$SYSNAME" in
case "$tag" in NetBSD)
*-NetBSD-*)
echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o pthread.o stkmalloc.o 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 echo ${SYSNAME}-${OBJTYPE}-asm.o ${SYSNAME}-${OBJTYPE}.o pthread.o stkmmap.o
;; ;;
*) *)