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

Bug#274367: glibc: [amd64] New GLIBC pass to create 32bit libc6-i386 and libc6-dev-i386 packages



Package: glibc
Severity: wishlist
Tags: patch

Finally, there is a patch which creates a 32bit i386 version of libc6
on amd64 by adding an extra pass to glibc. The new packages 'libc6-i386'
and 'libc6-dev-i386' install the 32bit libc6 files in /usr/lib32, which
is a symlink to '/emul/ia32-linux/usr/lib'. This location may look a 
bit strange first, but this is where the 'ia32-libs' package
installs all 32bit i386 libraries and files at the moment. 

The 'ia32-libs' package currently installs a libc6 binary package
which has been compiled by the i386 distribution. This is ugly because
it makes the whole amd64 distribution, especially the amd64 gcc compiler,
depend on binary packages from the i386 distribution.

Of course the 'ia32-libs' package will also have to be changed, 
so that it no longer installs libc6 by itself 
but simply depends on libc6-i386 instead.

The attached patch - together with a corresponding patch to ia32-libs -
has been used for a few weeks by the experimental amd64/gcc-3.4 archive
without problems so far.

Regards
Andreas Jochens


This patch changes the following files of the glibc package:

* debian/sysdeps/amd64.mk:

    Add an extra 'i386' pass which creates the packages 'libc6-i386' and 
    'libc6-dev-i386' containing a 32bit i386 version of the library 
    (this is much like the 'libc6-sparc64' or 'libc6-s390x' cases, 
    but this time the 64bit library is the native library and the 
    32bit library is the addititional one). 

    All following changes are necessary to correctly build the 'libc6-i386' 
    and 'libc6-dev-i386' packages on amd64:

* debian/control.in/main:
  
    Add Build-Depends on 'gcc-3.4 [amd64]' to be able to create 32bit 
    binaries.

* debian/control.in/amd64-i386 (new file):

    Control information for the 'libc6-i386' and 'libc6-dev-i386' packages.
  
* debian/debhelper.in/libc-dev-i386.install (new file),
  debian/debhelper.in/libc-i386.install (newfile),
  debian/debhelper.in/libc-i386.links (new file):

    Define the contents of the packages 'libc6-i386' and 'libc6-dev-i386'
    and move the files to the correct directories.
    Provide the symlinks /lib/ld-linux.so.2 and /usr/lib32.

* debian/debhelper.in/libc.preinst:

    On amd64 exclude '/usr/lib32' from the directories which are checked 
    for an installed version of libc. The 32bit i386 libc will be installed
    in '/usr/lib32' which is a symlink to '/emul/ia32-linux/usr/lib'.

* debian/rules.d/debhelper.mk:

    Prevent the use of the libc-otherbuild.* files if there is a special
    libc-*.install file for the pass. Without this patch the
    'libc-i386.install' file mentioned above would be overwritten by the
    'libc-otherbuild.install' file.

* debian/patches/arch-fixup-attribute.dpatch (new file):

    Patch from upstream CVS (necessary to compile the 32bit library on amd64):
    * sysdeps/i386/dl-machine.h: Define ARCH_FIXUP_ATTRIBUTE and use
      it in the fixup function declarations.
    * elf/dl-runtime.c: If ARCH_FIXUP_ATTRIBUTE is not defined,
      provide dummy definition.  Use macro in fixup function definitions.

* debian/patches/00list:

    Enable the new 'arch-fixup-attribute' patch.


diff -urN ../tmp-orig/glibc-2.3.2.ds1/debian/sysdeps/amd64.mk ./debian/sysdeps/amd64.mk
--- ../tmp-orig/glibc-2.3.2.ds1/debian/sysdeps/amd64.mk	2004-09-29 15:17:10.633727680 +0200
+++ ./debian/sysdeps/amd64.mk	2004-09-29 09:11:39.071831872 +0200
@@ -12,3 +12,18 @@
 ifeq ($(BUILD_CC_VERSION),3.4)
 	libc_extra_cflags += -g0
 endif
+
+# build 32bit i386 library
+GLIBC_PASSES += i386
+DEB_ARCH_REGULAR_PACKAGES += libc6-i386 libc6-dev-i386
+i386_CC = gcc-3.4 -m32
+i386_MIN_KERNEL_SUPPORTED = 2.6.0
+i386_configure_build = x86_64-linux
+i386_configure_target = i486-linux
+i386_add-ons = nptl $(add-ons)
+libc6-i386_shlib_dep = libc6-i386 (>= $(shlib_dep_ver))
+i386_extra_cflags = -O3 -fomit-frame-pointer -D__USE_STRING_INLINES
+i386_extra_cflags += -g0 -fno-unit-at-a-time
+i386_extra_config_options = $(extra_config_options) --with-tls --with-__thread \
+ --host=i486-linux --with-headers=/usr/include/i386-linux \
+ --prefix=/emul/ia32-linux/usr 
diff -urN ../tmp-orig/glibc-2.3.2.ds1/debian/control ./debian/control
--- ../tmp-orig/glibc-2.3.2.ds1/debian/control	2004-09-29 15:17:10.321775104 +0200
+++ ./debian/control	2004-09-29 09:11:39.071831872 +0200
@@ -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 | gcc-3.4, 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.4 [amd64], gcc-3.3 | gcc-3.4, autoconf, binutils (>= 2.14.90.0.7-5), sed (>= 4.0.5-4), gawk, debhelper (>= 4.1.76)
 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>
@@ -440,6 +440,26 @@
  Most notably, IBM's JDK. If you experience problems with such
  applications, you will need to remove this package.
 
+Package: libc6-i386
+Architecture: amd64
+Section: libs
+Priority: extra
+Depends: libc6 (= ${Source-Version}), lib32gcc1
+Description: GNU C Library: 32bit shared libraries for amd64
+ This package includes shared versions of the standard C
+ library and the standard math library, as well as many others.
+ This is the 32bit version of the library, meant for amd64 systems.
+
+Package: libc6-dev-i386
+Architecture: amd64
+Section: libdevel
+Priority: standard
+Depends: libc6-i386 (= ${Source-Version}), libc6-dev (= ${Source-Version})
+Description: GNU C Library: 32bit development libraries for amd64
+ Contains the symlinks and object files needed to compile and link programs
+ which use the standard C library. This is the 32bit version of the
+ library, meant for amd64 systems.
+
 Package: libnss-dns-udeb
 XC-Package-Type: udeb
 Architecture: any
diff -urN ../tmp-orig/glibc-2.3.2.ds1/debian/control.in/amd64_i386 ./debian/control.in/amd64_i386
--- ../tmp-orig/glibc-2.3.2.ds1/debian/control.in/amd64_i386	1970-01-01 01:00:00.000000000 +0100
+++ ./debian/control.in/amd64_i386	2004-09-29 09:11:39.072831720 +0200
@@ -0,0 +1,20 @@
+Package: libc6-i386
+Architecture: amd64
+Section: libs
+Priority: extra
+Depends: libc6 (= ${Source-Version}), lib32gcc1
+Description: GNU C Library: 32bit shared libraries for amd64
+ This package includes shared versions of the standard C
+ library and the standard math library, as well as many others.
+ This is the 32bit version of the library, meant for amd64 systems.
+
+Package: libc6-dev-i386
+Architecture: amd64
+Section: libdevel
+Priority: standard
+Depends: libc6-i386 (= ${Source-Version}), libc6-dev (= ${Source-Version})
+Description: GNU C Library: 32bit development libraries for amd64
+ Contains the symlinks and object files needed to compile and link programs
+ which use the standard C library. This is the 32bit version of the
+ library, meant for amd64 systems.
+
diff -urN ../tmp-orig/glibc-2.3.2.ds1/debian/control.in/main ./debian/control.in/main
--- ../tmp-orig/glibc-2.3.2.ds1/debian/control.in/main	2004-09-29 15:17:10.280781336 +0200
+++ ./debian/control.in/main	2004-09-29 09:11:39.072831720 +0200
@@ -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 | gcc-3.4, 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.4 [amd64], gcc-3.3 | gcc-3.4, autoconf, binutils (>= 2.14.90.0.7-5), sed (>= 4.0.5-4), gawk, debhelper (>= 4.1.76)
 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 -urN ../tmp-orig/glibc-2.3.2.ds1/debian/debhelper.in/libc-dev-i386.install ./debian/debhelper.in/libc-dev-i386.install
--- ../tmp-orig/glibc-2.3.2.ds1/debian/debhelper.in/libc-dev-i386.install	1970-01-01 01:00:00.000000000 +0100
+++ ./debian/debhelper.in/libc-dev-i386.install	2004-09-29 09:11:39.072831720 +0200
@@ -0,0 +1,4 @@
+debian/tmp-i386/emul/ia32-linux/usr/lib/*.a* emul/ia32-linux/usr/lib
+debian/tmp-i386/emul/ia32-linux/usr/lib/*.o emul/ia32-linux/usr/lib
+debian/tmp-i386/emul/ia32-linux/usr/include/* emul/ia32-linux/usr/include
+debian/tmp-i386/emul/ia32-linux/usr/bin/* emul/ia32-linux/usr/bin
diff -urN ../tmp-orig/glibc-2.3.2.ds1/debian/debhelper.in/libc-i386.install ./debian/debhelper.in/libc-i386.install
--- ../tmp-orig/glibc-2.3.2.ds1/debian/debhelper.in/libc-i386.install	1970-01-01 01:00:00.000000000 +0100
+++ ./debian/debhelper.in/libc-i386.install	2004-09-29 09:11:39.073831568 +0200
@@ -0,0 +1,2 @@
+debian/tmp-i386/emul/ia32-linux/usr/lib/*.so* emul/ia32-linux/usr/lib
+debian/tmp-i386/emul/ia32-linux/usr/lib/gconv/*.so* emul/ia32-linux/usr/lib/gconv
diff -urN ../tmp-orig/glibc-2.3.2.ds1/debian/debhelper.in/libc-i386.links ./debian/debhelper.in/libc-i386.links
--- ../tmp-orig/glibc-2.3.2.ds1/debian/debhelper.in/libc-i386.links	1970-01-01 01:00:00.000000000 +0100
+++ ./debian/debhelper.in/libc-i386.links	2004-09-29 09:11:39.073831568 +0200
@@ -0,0 +1,2 @@
+/emul/ia32-linux/usr/lib/ld-linux.so.2 /lib/ld-linux.so.2
+/emul/ia32-linux/usr/lib /usr/lib32
diff -urN ../tmp-orig/glibc-2.3.2.ds1/debian/debhelper.in/libc.preinst ./debian/debhelper.in/libc.preinst
--- ../tmp-orig/glibc-2.3.2.ds1/debian/debhelper.in/libc.preinst	2004-09-29 15:17:10.312776472 +0200
+++ ./debian/debhelper.in/libc.preinst	2004-09-29 15:16:52.798439056 +0200
@@ -145,7 +145,12 @@
 then
   dirs="/usr/local/lib /usr/local/lib32 /usr/local/lib64"
   if ! test -L /usr; then
-    dirs="$dirs /usr/lib /usr/lib32 /usr/lib64"
+    if [ `dpkg-architecture -qDEB_HOST_ARCH` = "amd64" ]; then
+      # the 32bit i386 libc may be installed in /usr/lib32 on amd64
+      dirs="$dirs /usr/lib /usr/lib64"
+    else
+      dirs="$dirs /usr/lib /usr/lib32 /usr/lib64"
+    fi
   fi
   if check_dirs $dirs; then
     echo
diff -urN ../tmp-orig/glibc-2.3.2.ds1/debian/patches/00list ./debian/patches/00list
--- ../tmp-orig/glibc-2.3.2.ds1/debian/patches/00list	2004-09-29 15:17:10.323774800 +0200
+++ ./debian/patches/00list	2004-09-29 09:12:07.094571768 +0200
@@ -109,4 +109,4 @@
 glibc23-dlclose-l_opencount
 glibc232-globfree-clear
 # nptl-pthread-create-attr - disabled to worry about the ABI/function breakage
-
+arch-fixup-attribute
diff -urN ../tmp-orig/glibc-2.3.2.ds1/debian/patches/arch-fixup-attribute.dpatch ./debian/patches/arch-fixup-attribute.dpatch
--- ../tmp-orig/glibc-2.3.2.ds1/debian/patches/arch-fixup-attribute.dpatch	1970-01-01 01:00:00.000000000 +0100
+++ ./debian/patches/arch-fixup-attribute.dpatch	2004-09-29 09:11:39.074831416 +0200
@@ -0,0 +1,82 @@
+#! /bin/sh -e
+ 
+# All lines beginning with `# DP:' are a description of the patch.
+# DP: * sysdeps/i386/dl-machine.h: Define ARCH_FIXUP_ATTRIBUTE and use
+# DP:   it in the fixup function declarations.
+# DP: * elf/dl-runtime.c: If ARCH_FIXUP_ATTRIBUTE is not defined,
+# DP:   provide dummy definition.  Use macro in fixup function
+# DP:   definitions.
+# DP: Dpatch author: Andreas Jochens <aj@andaco.de>
+# DP: Patch author: Ulrich Drepper <drepper@redhat.com>
+# DP: Upstream status: in CVS
+# DP: Status Details: 
+# DP: Date: 2004-03-08
+
+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.
+--- dl-machine.h	2004-08-05 14:30:44.417038000 +0000
++++ glibc-2.3.2/sysdeps/i386/dl-machine.h	2004-08-05 19:44:35.661107637 +0000
+@@ -155,11 +155,14 @@
+    destroys the passed register information.  */
+ /* GKM FIXME: Fix trampoline to pass bounds so we can do
+    without the `__unbounded' qualifier.  */
+-static ElfW(Addr) fixup (struct link_map *__unbounded l, ElfW(Word) reloc_offset)
+-     __attribute__ ((regparm (2), unused));
++#define ARCH_FIXUP_ATTRIBUTE __attribute__ ((regparm (3), unused))
++
++static ElfW(Addr) fixup (struct link_map *__unbounded l,
++			 ElfW(Word) reloc_offset)
++     ARCH_FIXUP_ATTRIBUTE;
+ static ElfW(Addr) profile_fixup (struct link_map *l, ElfW(Word) reloc_offset,
+ 				 ElfW(Addr) retaddr)
+-     __attribute__ ((regparm (3), unused));
++     ARCH_FIXUP_ATTRIBUTE;
+ # endif
+ 
+ /* This code is used in dl-runtime.c to call the `fixup' function
+--- dl-runtime.c	2003-02-07 19:41:12.000000000 +0000
++++ glibc-2.3.2/elf/dl-runtime.c	2004-08-05 19:48:48.885006003 +0000
+@@ -36,6 +36,12 @@
+ # define VERSYMIDX(sym)	(DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (sym))
+ #endif
+ 
++/* The fixup functions might have need special attributes.  If none
++   are provided define the macro as empty.  */
++#ifndef ARCH_FIXUP_ATTRIBUTE
++# define ARCH_FIXUP_ATTRIBUTE
++#endif
++
+ 
+ /* This function is called through a special trampoline from the PLT the
+    first time each PLT entry is called.  We must perform the relocation
+@@ -45,7 +51,8 @@
+    function.  */
+ 
+ #ifndef ELF_MACHINE_NO_PLT
+-static ElfW(Addr) __attribute_used__
++static ElfW(Addr) 
++__attribute ((used, noinline)) ARCH_FIXUP_ATTRIBUTE
+ fixup (
+ # ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
+         ELF_MACHINE_RUNTIME_FIXUP_ARGS,
+@@ -133,6 +140,7 @@
+ #if !defined PROF && !defined ELF_MACHINE_NO_PLT && !__BOUNDED_POINTERS__
+ 
+-static ElfW(Addr) __attribute_used__
++static ElfW(Addr)
++__attribute ((used, noinline)) ARCH_FIXUP_ATTRIBUTE
+ profile_fixup (
+ #ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
+        ELF_MACHINE_RUNTIME_FIXUP_ARGS,
diff -urN ../tmp-orig/glibc-2.3.2.ds1/debian/rules.d/control.mk ./debian/rules.d/control.mk
--- ../tmp-orig/glibc-2.3.2.ds1/debian/rules.d/control.mk	2004-09-29 15:17:10.626728744 +0200
+++ ./debian/rules.d/control.mk	2004-09-29 09:11:39.072831720 +0200
@@ -22,6 +22,7 @@
 	cat debian/control.in/libc6.1		>> $@T
 	cat debian/control.in/libc0.3		>> $@T
 	cat debian/control.in/libc1		>> $@T
+	cat debian/control.in/amd64_i386	>> $@T
 	cat debian/control.in/sparc64		>> $@T
 	cat debian/control.in/s390x		>> $@T
 	cat debian/control.in/opt		>> $@T
diff -urN ../tmp-orig/glibc-2.3.2.ds1/debian/rules.d/debhelper.mk ./debian/rules.d/debhelper.mk
--- ../tmp-orig/glibc-2.3.2.ds1/debian/rules.d/debhelper.mk	2004-09-29 15:17:10.627728592 +0200
+++ ./debian/rules.d/debhelper.mk	2004-09-29 09:11:39.073831568 +0200
@@ -183,7 +183,7 @@
 	    sed -e "s#LIBC#$(libc)#" -i $$z; \
 	    sed -e "s#DESTLIBDIR#$$destdir#" -i $$zd; \
 	    sed -e "s/^#.*//" -i $$zd; \
-	  else \
+	  elif [ ! -e $$z ]; then \
 	    cp debian/debhelper.in/libc-otherbuild.install $$z; \
 	    cp debian/debhelper.in/libc-otherbuild.preinst debian/$(libc)-$$x.preinst ; \
 	    cp debian/debhelper.in/libc-otherbuild.postinst debian/$(libc)-$$x.postinst ; \



Reply to: