[patch] fix building linuxthreads with tls support for i[45]86 hosts (BZ674)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[patch] fix building linuxthreads with tls support for i[45]86 hosts (BZ674)

Mike Frysinger
http://sources.redhat.com/bugzilla/show_bug.cgi?id=674

if you try and build glibc-2.3.6 with linuxthreads and with tls support
enabled for an i486 or i586 target, the build fails

"Nix" investigated the issue in the mentioned bug report and the attached
patch is the result ... just compile tested and some basic runtime tests in
Gentoo
-mike

The i686 pt-machine.h includes useldt.h so that USE_TLS/HAVE___THREAD are
properly defined.  The generic i386 pt-machine.h header does not pull in
useldt.h however, so when building linuxthreads with TLS support for i586,
the final fails:
...
linuxthreads/libpthread_pic.a(pthread.os)(.text+0x161): In function `__pthread_initialize':
: undefined reference to `_res'
linuxthreads/libpthread_pic.a(pthread.os)(.text+0x107a): In function `__pthread_reset_main_thread':
: undefined reference to `_h_errno'
linuxthreads/libpthread_pic.a(pthread.os)(.text+0x1089): In function `__pthread_reset_main_thread':
: undefined reference to `_errno'
...

So, to reiterate, this is due to some parts of linuxthreads being incorrectly
built without the TLS defines.

http://sources.redhat.com/bugzilla/show_bug.cgi?id=674
http://bugs.gentoo.org/90236

2006-04-24  Mike Frysinger  <[hidden email]>

        * sysdeps/i386/pt-machine.h: Include kernel-features.h.
        [__ASSUME_LDT_WORKS]: Include useldt.h.

--- linuxthreads/sysdeps/i386/pt-machine.h
+++ linuxthreads/sysdeps/i386/pt-machine.h
@@ -26,6 +26,7 @@
 #ifndef PT_EI
 # define PT_EI extern inline __attribute__ ((always_inline))
 #endif
+#include "kernel-features.h"
 
 extern long int testandset (int *spinlock);
 extern int __compare_and_swap (long int *p, long int oldval, long int newval);
@@ -105,4 +106,8 @@ compare_and_swap_is_available (void)
 }
 #endif /* __ASSEMBLER__ */
 
+#if __ASSUME_LDT_WORKS > 0
+#include "useldt.h"
+#endif
+
 #endif /* pt-machine.h */
Reply | Threaded
Open this post in threaded view
|

Re: [patch] fix building linuxthreads with tls support for i[45]86 hosts (BZ674)

Daniel Jacobowitz-2
On Mon, Apr 24, 2006 at 08:14:53PM -0400, Mike Frysinger wrote:
> http://sources.redhat.com/bugzilla/show_bug.cgi?id=674
>
> if you try and build glibc-2.3.6 with linuxthreads and with tls support
> enabled for an i486 or i586 target, the build fails
>
> "Nix" investigated the issue in the mentioned bug report and the attached
> patch is the result ... just compile tested and some basic runtime tests in
> Gentoo

This isn't the same as BZ674; it's a related tangent (mentioned in the
comments).  I've updated that.

I've also committed Petr's more thorough patch for this.  It should
work now.

--
Daniel Jacobowitz
CodeSourcery