[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#318429: glibc: Patch for the TLS problem



Package: glibc
Followup-For: Bug #317946

Hi,

I reassigned this bug to glibc after testing an old patch for the TLS
problem for Kurt Roeckx. I had to fix a few other things along the
way:

    - debian/patches/amd64-TLS-problem.dpatch: try to fix TLS problem
    - debain/rules: undo dpkg-architecture output changes
    - debian/sysdeps/amd64.mk: use gcc-3.4
    - debian/control: 'Build-Depends: gcc-3.4 [amd64]' to be sure

After build I tried to compile

int main(){return 0;}

with 'gcc -O2 -W -Wall -static -o foo foo.c' both with the old and new
packages. The old ones report the TLS problem while the new ones work.

MfG
	Goswin

-- System Information:
Debian Release: 3.1
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.8-frosties-1
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
diff -u glibc-2.3.2.ds1/debian/patches/00list glibc-2.3.2.ds1/debian/patches/00list
--- glibc-2.3.2.ds1/debian/patches/00list
+++ glibc-2.3.2.ds1/debian/patches/00list
@@ -127,0 +128 @@
+amd64-TLS-problem
diff -u glibc-2.3.2.ds1/debian/sysdeps/amd64.mk glibc-2.3.2.ds1/debian/sysdeps/amd64.mk
--- glibc-2.3.2.ds1/debian/sysdeps/amd64.mk
+++ glibc-2.3.2.ds1/debian/sysdeps/amd64.mk
@@ -1,5 +1,5 @@
-CC = gcc
-BUILD_CC = gcc
+CC = gcc-3.4
+BUILD_CC = gcc-3.4
 
 # build libc with nptl instead of linuxthreads
 libc_MIN_KERNEL_SUPPORTED = 2.6.0
diff -u glibc-2.3.2.ds1/debian/changelog glibc-2.3.2.ds1/debian/changelog
--- glibc-2.3.2.ds1/debian/changelog
+++ glibc-2.3.2.ds1/debian/changelog
@@ -1,3 +1,14 @@
+glibc (2.3.2.ds1-22.0.0.1.mrvn) unstable; urgency=low
+
+  * Goswin von Brederlow <brederlo@informatik.uni-tuebingen.de>
+
+    - debian/patches/amd64-TLS-problem.dpatch: try to fix TLS problem
+    - debain/rules: undo dpkg-architecture output changes
+    - debian/sysdeps/amd64.mk: use gcc-3.4
+    - debian/control: 'Build-Depends: gcc-3.4 [amd64]' to be sure
+
+ -- Goswin von Brederlow <brederlo@informatik.uni-tuebingen.de>  Sun, 17 Jul 2005 16:36:19 +0200
+
 glibc (2.3.2.ds1-22) unstable; urgency=medium
 
   * Daniel Jacobowitz <dan@debian.org>
diff -u glibc-2.3.2.ds1/debian/control glibc-2.3.2.ds1/debian/control
--- glibc-2.3.2.ds1/debian/control
+++ glibc-2.3.2.ds1/debian/control
@@ -1,7 +1,7 @@
 Source: glibc
 Section: libs
 Priority: required
-Build-Depends: gettext (>= 0.10.37-1), make (>= 3.80-1), dpkg-dev (>= 1.4.1.5), debianutils (>= 1.13.1), tar (>= 1.13.11), bzip2, texinfo (>= 4.0), linux-kernel-headers (>= 2.5.999-test7-bk-9) [!hurd-i386], mig (>= 1.3-2) [hurd-i386], hurd-dev (>= 20020608-1) [hurd-i386], gnumach-dev [hurd-i386], texi2html, file, gcc-3.3 [!ia64] | gcc-3.4 [!ia64], gcc-3.3 (>= 1:3.3.5-5) [ia64] | gcc-3.4 (>= 3.4.3-2) [ia64], autoconf, binutils (>= 2.14.90.0.7-5), sed (>= 4.0.5-4), gawk, debhelper (>= 4.1.76)
+Build-Depends: gettext (>= 0.10.37-1), make (>= 3.80-1), dpkg-dev (>= 1.4.1.5), debianutils (>= 1.13.1), tar (>= 1.13.11), bzip2, texinfo (>= 4.0), linux-kernel-headers (>= 2.5.999-test7-bk-9) [!hurd-i386], mig (>= 1.3-2) [hurd-i386], hurd-dev (>= 20020608-1) [hurd-i386], gnumach-dev [hurd-i386], texi2html, file, gcc-3.3 [!ia64] | gcc-3.4 [!ia64], gcc-3.3 (>= 1:3.3.5-5) [ia64] | gcc-3.4 (>= 3.4.3-2) [ia64], autoconf, binutils (>= 2.14.90.0.7-5), sed (>= 4.0.5-4), gawk, debhelper (>= 4.1.76), gcc-3.4 [amd64]
 Build-Depends-Indep: perl, po-debconf
 Maintainer: GNU Libc Maintainers <debian-glibc@lists.debian.org>
 Uploaders: Ben Collins <bcollins@debian.org>, GOTO Masanori <gotom@debian.org>, Philip Blundell <pb@nexus.co.uk>, Jeff Bailey <jbailey@raspberryginger.com>, Daniel Jacobowitz <dan@debian.org>
diff -u glibc-2.3.2.ds1/debian/rules glibc-2.3.2.ds1/debian/rules
--- glibc-2.3.2.ds1/debian/rules
+++ glibc-2.3.2.ds1/debian/rules
@@ -48,6 +48,12 @@
 DEB_BUILD_GNU_TYPE    ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
 DEB_BUILD_GNU_SYSTEM  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)
 
+# Strip newly added -gnu
+DEB_HOST_GNU_TYPE     := $(subst -gnu,,$(DEB_HOST_GNU_TYPE))
+DEB_HOST_GNU_SYSTEM   := $(subst -gnu,,$(DEB_HOST_GNU_SYSTEM))
+DEB_BUILD_GNU_TYPE    := $(subst -gnu,,$(DEB_BUILD_GNU_TYPE))
+DEB_BUILD_GNU_SYSTEM  := $(subst -gnu,,$(DEB_BUILD_GNU_SYSTEM))
+
 DEB_HOST_GNU_CPU_ALT  ?=
 DEB_HOST_GNU_TYPE_ALT ?=
 
only in patch2:
unchanged:
--- glibc-2.3.2.ds1.orig/debian/patches/amd64-TLS-problem.dpatch
+++ glibc-2.3.2.ds1/debian/patches/amd64-TLS-problem.dpatch
@@ -0,0 +1,91 @@
+#! /bin/sh -e
+ 
+# All lines beginning with `# DP:' are a description of the patch.
+# DP: Description: * elf/Makefile (rtld-routines): Add dl-errno.
+# DP:  ($(objpfx)librtld.map): Copy libc_pic.a to libc_pic.a, remove
+# DP:  errno.os from libc_pic.a and use libc_rtld.a instead of
+# DP:  libc_pic.a.
+# DP:  ($(objpfx)librtld.mk): Match libc_rtld.a instead of libc_pic.a.
+# DP: Dpatch author: Goswin von Brederlow <brederlo@informatik.uni-tuebingen.de>
+# DP: Patch author: H.J. Lu  <hongjiu.lu@intel.com>
+# DP: Upstream status: 
+# DP: Status Details: 
+# DP: Date: 2005-06-17
+
+if [ $# -ne 2 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+case "$1" in
+    -patch) patch -d "$2" -f --no-backup-if-mismatch -p1 < $0;;
+    -unpatch) patch -d "$2" -f --no-backup-if-mismatch -R -p1 < $0;;
+    *)
+        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+        exit 1
+esac
+exit 0
+ 
+# append the patch here and adjust the -p? flag in the patch calls.
+--- glibc-2.3.2/elf/Makefile~	2005-07-17 14:11:18.695803164 +0000
++++ glibc-2.3.2/elf/Makefile	2005-07-17 14:15:11.317292281 +0000
+@@ -37,7 +37,8 @@
+ 
+ # ld.so uses those routines, plus some special stuff for being the program
+ # interpreter and operating independent of libc.
+-rtld-routines	:= rtld $(dl-routines) dl-sysdep dl-environ dl-minimal
++rtld-routines := rtld $(dl-routines) dl-sysdep dl-environ \
++		     dl-minimal dl-errno
+ all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines)
+ 
+ # We only need to re-run initializers if ld.so and libc.so might be built
+@@ -220,11 +221,17 @@
+ # those modules come from and builds special rtld-foo.os versions that
+ # are compiled with special flags, and puts these modules into rtld-libc.a
+ # for us.  Then we do the real link using rtld-libc.a instead of libc_pic.a.
++# `errno' is a special case. We don't want the one in libc_pic.a since
++# `errno' in libc_pic.a may be a TLS, but the dynamic linker doesn't
++# use TLS. The linker doesn't allow mixing TLS and non-TLS symbols.
+ 
+ $(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
+ 	@-rm -f $@T
+-	$(reloc-link) -o $@.o '-Wl,-(' $^ -lgcc '-Wl,-)' -Wl,-Map,$@T
+-	rm -f $@.o
++	@rm -f libc_rtld.a
++	cp $(common-objpfx)libc_pic.a $(common-objpfx)libc_rtld.a
++	$(AR) d$(verbose) $(common-objpfx)libc_rtld.a errno.os
++	$(reloc-link) -o $@.o '-Wl,-(' $(objpfx)dl-allobjs.os $(common-objpfx)libc_rtld.a -lgcc '-Wl,-)' -Wl,-Map,$@T
++	rm -f $@.o $(common-objpfx)libc_rtld.a
+ 	mv -f $@T $@
+ 
+ $(objpfx)librtld.mk: $(objpfx)librtld.map Makefile
+@@ -233,7 +240,7 @@
+ 	    $< | \
+ 	while read lib file; do \
+ 	  case $$lib in \
+-	  libc_pic.a) \
++	  libc_rtld.a) \
+ 	    LC_ALL=C fgrep -l /$$file \
+ 		  $(common-objpfx)stamp.os $(common-objpfx)*/stamp.os | \
+ 	    LC_ALL=C \
+--- glibc-2.3.2/elf/dl-errno.c.tls		2004-10-01 14:57:23.000000000 -0700
++++ glibc-2.3.2/elf/dl-errno.c		2004-10-01 15:34:30.000000000 -0700
+@@ -0,0 +1,19 @@
++/* Copyright (C) 2004 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library is distributed in the hope that it will be useful,
++   but WITHOUT ANY WARRANTY; without even the implied warranty of
++   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, write to the Free
++   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++   02111-1307 USA.  */
++
++#include <errno.c>

Reply to: