Proposed patch for binutils x32 support
I've been spending some time this week bootstrapping an x32 chroot on my
machine. Right now I have the basics compiled and installed (and packed up
into dummy .deb files without any dependencies or anything). So now I'm going
through and trying to compile the actual Debian packages.
Here's the patch I applied to binutils to get it to support x32 multiarch
directories. I tested that it does allow me to link against libraries in
/usr/lib/x86_64-linux-gnux32 (libapt-pkg.so to be exact), which I couldn't
before.
So I thought I'd post the patch for comments first. Anything glaringly wrong
with it, or missing from it? If it looks OK, I'll go ahead and file a wishlist
bug against binutils to get it applied.
(As for the other major toolchain components: glibc/eglibc will have to wait
for an upgrade for any x32 updates to be incorporated, as x32 support is only
available starting in 2.15. And for gcc-4.7, I'd need to generate a patch to
incorporate HJ's branch implementing the --with-abi=mx32 option.)
--
Daniel Schepler
diff -urN binutils-2.22.old/debian/changelog binutils-2.22/debian/changelog
--- binutils-2.22.old/debian/changelog 2012-06-07 19:30:04.000000000 -0700
+++ binutils-2.22/debian/changelog 2012-06-07 19:29:17.000000000 -0700
@@ -1,3 +1,9 @@
+binutils (2.22-6.1+x32) UNRELEASED; urgency=low
+
+ * Update multi-arch path to handle x32 (x86_64-linux-gnux32) correctly.
+
+ -- Daniel Schepler <schepler@debian.org> Thu, 07 Jun 2012 19:28:48 -0700
+
binutils (2.22-6.1) unstable; urgency=low
* Non-maintainer upload.
diff -urN binutils-2.22.old/debian/patches/129_ld_mulitarch_dirs.patch binutils-2.22/debian/patches/129_ld_mulitarch_dirs.patch
--- binutils-2.22.old/debian/patches/129_ld_mulitarch_dirs.patch 2012-06-07 19:30:04.000000000 -0700
+++ binutils-2.22/debian/patches/129_ld_mulitarch_dirs.patch 2012-06-07 19:20:22.000000000 -0700
@@ -1,10 +1,10 @@
# DP: Add multiarch directories to linker search path.
-Index: binutils-2.21.0.20110322/ld/genscripts.sh
+Index: binutils-2.22/ld/genscripts.sh
===================================================================
---- binutils-2.21.0.20110322.orig/ld/genscripts.sh 2011-03-27 18:45:12.283057003 +0000
-+++ binutils-2.21.0.20110322/ld/genscripts.sh 2011-03-27 18:51:20.623057182 +0000
-@@ -240,6 +240,65 @@
+--- binutils-2.22.orig/ld/genscripts.sh 2010-12-15 06:56:37.000000000 -0800
++++ binutils-2.22/ld/genscripts.sh 2012-06-07 19:19:15.000000000 -0700
+@@ -242,6 +242,79 @@
fi
LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'`
@@ -41,7 +41,7 @@
+ ;;
+ */lib64)
+ case "${target}" in
-+ powerpc64-*-*|s390x-*-*|sparc64-*-*|x86_64-*-linux*)
++ powerpc64-*-*|s390x-*-*|sparc64-*-*|x86_64-*-linux-gnu)
+ #dir=$(echo $dir | sed "s,64$,,")
+ dir2=$(echo $dir | sed "s,64$,,")
+ temp_dirs="${temp_dirs}${dir2}/$DEB_HOST_MULTIARCH "
@@ -54,6 +54,20 @@
+ ;;
+ esac
+ ;;
++ */libx32)
++ case "${target}" in
++ x86_64-*-linux-gnux32)
++ dir2=$(echo $dir | sed "s,x32$,,")
++ temp_dirs="${temp_dirs}${dir2}/$DEB_HOST_MULTIARCH "
++ ;;
++ *)
++ if [ -n "$DEB_HOST_MULTIARCHX32" ]; then
++ dir2=$(echo $dir | sed "s,x32$,,")
++ temp_dirs="${temp_dirs}${dir2}/$DEB_HOST_MULTIARCHX32 "
++ fi
++ ;;
++ esac
++ ;;
+ *)
+ ;;
+ esac
diff -urN binutils-2.22.old/debian/rules binutils-2.22/debian/rules
--- binutils-2.22.old/debian/rules 2012-06-07 19:30:04.000000000 -0700
+++ binutils-2.22/debian/rules 2012-06-07 18:10:16.000000000 -0700
@@ -166,6 +166,10 @@
ifeq ($(DEB_HOST_MULTIARCH),x86_64-linux-gnu)
DEB_HOST_MULTIARCH32 = i386-linux-gnu
+ DEB_HOST_MULTIARCHX32 = x86_64-linux-gnux32
+else ifeq ($(DEB_HOST_MULTIARCH),x86_64-linux-gnux32)
+ DEB_HOST_MULTIARCH32 = i386-linux-gnu
+ DEB_HOST_MULTIARCH64 = x86_64-linux-gnu
else ifeq ($(DEB_HOST_MULTIARCH),powerpc64-linux-gnu)
DEB_HOST_MULTIARCH32 = powerpc-linux-gnu
else ifeq ($(DEB_HOST_MULTIARCH),s390x-linux-gnu)
@@ -176,6 +180,7 @@
DEB_HOST_MULTIARCH32 = i386-kfreebsd-gnu
else ifeq ($(DEB_HOST_MULTIARCH),i386-linux-gnu)
DEB_HOST_MULTIARCH64 = x86_64-linux-gnu
+ DEB_HOST_MULTIARCHX32 = x86_64-linux-gnux32
else ifeq ($(DEB_HOST_MULTIARCH),powerpc-linux-gnu)
DEB_HOST_MULTIARCH64 = powerpc64-linux-gnu
else ifeq ($(DEB_HOST_MULTIARCH),sparc-linux-gnu)
@@ -190,6 +195,7 @@
DEB_HOST_MULTIARCH64 = mips64el-linux-gnu
endif
export DEB_HOST_MULTIARCH DEB_HOST_MULTIARCH32 DEB_HOST_MULTIARCH64
+export DEB_HOST_MULTIARCHX32
ifeq ($(DEB_HOST_ARCH),sparc)
CONFARGS += --enable-targets=sparc64-linux-gnu
@@ -212,7 +218,7 @@
CONFARGS += --enable-targets=s390-linux-gnu
endif
ifeq ($(DEB_HOST_ARCH),i386)
- CONFARGS += --enable-targets=x86_64-linux-gnu
+ CONFARGS += --enable-targets=x86_64-linux-gnu,x86_64-linux-gnux32
endif
ifeq ($(DEB_HOST_ARCH),kfreebsd-i386)
CONFARGS += --enable-targets=x86_64-kfreebsd-gnu
@@ -389,6 +395,7 @@
sparc-linux-gnu \
sparc64-linux-gnu \
x86_64-linux-gnu \
+ x86_64-linux-gnux32 \
m32r-linux-gnu \
spu
@@ -1142,12 +1149,12 @@
ADDITIONAL_TARGETS = --enable-targets=$(TARGET:%-linux-gnu=%64-linux-gnu)
endif
ifneq ($(filter i386-linux-gnu i486-linux-gnu i586-linux-gnu i686-linux-gnu x86-linux-gnu, $(TARGET)),)
-ADDITIONAL_TARGETS = --enable-targets=x86_64-linux-gnu
+ADDITIONAL_TARGETS = --enable-targets=x86_64-linux-gnu,x86_64-linux-gnux32
endif
ifneq ($(filter i386-kfreebsd-gnu i486-kfreebsd-gnu i586-kfreebsd-gnu x86-kfreebsd-gnu, $(TARGET)),)
-ADDITIONAL_TARGETS = --enable-targets=x86_64-linux-gnu
+ADDITIONAL_TARGETS = --enable-targets=x86_64-linux-gnu,x86_64-linux-gnux32
endif
-ifeq ($(TARGET), x86_64-linux-gnu)
+ifneq ($(filter x86_64-linux-gnu x86_64-linux-gnux32, $(TARGET)),)
ADDITIONAL_TARGETS = --enable-targets=i486-linux-gnu
endif
ifeq ($(TARGET), x86_64-kfreebsd-gnu)
Reply to: