mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
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:
parent
8d82ccefd2
commit
cb8f735786
9 changed files with 28 additions and 130 deletions
17
INSTALL
17
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..."
|
||||
|
|
8
bin/9c
8
bin/9c
|
@ -103,14 +103,6 @@ case "$tag" in
|
|||
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;
|
||||
|
|
7
bin/9l
7
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"
|
||||
|
|
|
@ -66,10 +66,8 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
|
|||
|
||||
#if defined(__linux__)
|
||||
# include <sys/types.h>
|
||||
# if defined(__Linux26__)
|
||||
# include <pthread.h>
|
||||
# define PLAN9PORT_USING_PTHREADS 1
|
||||
# endif
|
||||
# if defined(__USE_MISC)
|
||||
# undef _NEEDUSHORT
|
||||
# undef _NEEDUINT
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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.
|
||||
|
|
|
@ -76,20 +76,9 @@ prints suggested settings for the environment variables
|
|||
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
|
||||
|
|
|
@ -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.
|
||||
|
|
@ -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
|
||||
;;
|
||||
*)
|
||||
|
|
Loading…
Reference in a new issue