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

Re: Bug#180128: state of integration of dpkg-cross into dpkg



On Sun, 2012-07-22 at 21:45 +0200, Guillem Jover wrote: 
> On Sun, 2012-07-22 at 10:52:19 -0700, shawn wrote:
> > On Sun, 2012-07-22 at 19:46 +0200, Guillem Jover wrote: 
> > > On Sun, 2012-07-22 at 18:35:16 +0100, Neil Williams wrote:
> > > > I'd be happy if this bug is closed with an upload of dpkg which extends
> > > > the cputable data to complete the ABI declarations with the
> > > > architecture-specific values from which dpkg-cross / replacement can
> > > > derive the cache values.
> > > 
> > > Ok, perfect, then I'll prepare and queue this for 1.17.x.
> 
> > Will this allow me to query the the 64-bit complement of a 32-bit arch,
> > and visa versa?
> 
> No, not really. The main problem is that there's cases where there's
> no obvious 1:1 mapping, take i386/x32/amd64 or arm/armel/armhf/arm64,
> or mips where there's three ABIs, etc. And I don't think this is
> generally useful anyway, less so now with multiarch when multilib
> packages will be disappearing.
> 
> > I would be using this for a patch making dpkg cross-building work with
> > gcc's multilib in gcc-defaults package.
> 
> I think I've mentioned this before, but gcc already has (and needs)
> knowledge about the multilib “pairs” and as such it makes sense to
> keep that knowdlege localized there.
Well that was the idea. How would you suggest I approach this (patch
attached) that pushes the logic out to the gcc-defaults/multilib stuff.
It does not include the needed binutils symlinks. Suggestions on where
those should go is wanted.

Where is this logic that i can tap into for creating these symlinks if
not in dpkg? 
> 
> thanks,
> guillem


-- 
-Shawn Landden
>From 8cac76fb8c00fb3429e651994d001ca6c9ad02f5 Mon Sep 17 00:00:00 2001
From: Shawn Landden <shawnlandden@gmail.com>
Date: Sat, 21 Jul 2012 15:55:58 -0700
Subject: [PATCH] provide fully qualified compiler names in the multilib
 infrastructure

This means that you can use dpkg's multi-arch cross-compile features
with multilib, like so: (on i386)

apt-get install gcc-multilib build-essential
apt-get build-dep -aamd64 iceweasel
apt-get source iceweasel
cd iceweasel-*
dpkg-buildpackage -aamd64
---
 debian/rules |   42 +++++++++++++++++++++++++++++++++++++++++-
 gcc-32       |   19 +++++++++++++++++++
 gcc-64       |   19 +++++++++++++++++++
 3 files changed, 79 insertions(+), 1 deletion(-)
 create mode 100755 gcc-32
 create mode 100755 gcc-64

diff --git a/debian/rules b/debian/rules
index 9a14d93..385402f 100755
--- a/debian/rules
+++ b/debian/rules
@@ -352,6 +352,25 @@ PV_GIJ	:= $(shell echo $(V_GIJ)   | awk -F. '{printf "%d.%d", $$1, $$2}')
 PV_GPC	:= $(shell echo $(V_GPC)   | awk -F. '{printf "%d.%d", $$1, $$2}')
 PV_SPU	:= $(shell echo $(V_SPU)   | awk -F. '{printf "%d.%d", $$1, $$2}')
 
+# multilib_archs = amd64 i386 kfreebsd-amd64 mips mipsel powerpc ppc64 s390 s390x sparc
+# multilib variables
+MULTILIB_amd64 := i386
+MULTILIB_i386 := amd64
+MULTILIB_kfreebsd-amd64 := kfreebsd-i386
+MULTILIB_mips := i386
+MULTILIB_powerpc := ppc64
+MULTILIB_ppc64 := powerpc
+MULTILIB_s390 := s390x
+MULTILIB_s390x := s390
+MULTILIB_sparc := sparc64
+#MULTILIB_mips := mips64 # need to add mips64/mips64el to dpkg
+#MULTILIB_mipsel := mips64el
+#MULTILIB_mips_gnu := mips64-linux-gnuabi64 # does not work well with d-a -t, because dpkg does not know bitness
+#MULTILIB_mipsel_gnu := mips64el-linux-gnuabi64
+multilib_arch := ${MULTILIB_${DEB_HOST_ARCH}}
+multilib_gnu_type := $(shell dpkg-architecture -f -a${multilib_arch} -qDEB_HOST_GNU_TYPE)
+multilib_bits := $(shell dpkg-architecture -f -a${multilib_arch} -qDEB_HOST_ARCH_BITS)
+
 README:
 	m4 -DPACKAGES="$(packages)" \
 	   -DOS_NAME=$(OS_NAME) \
@@ -552,7 +571,28 @@ ifeq ($(with_multiarch_lib),yes)
 	# have separate asm headers installed for our non-default targets.
 	dh_link -pgcc-multilib \
 	  /usr/include/$(DEB_HOST_MULTIARCH)/asm /usr/include/asm
-  endif  
+
+  ifdef MULTILIB_${DEB_HOST_ARCH}
+	# wrapper so that gcc-multilib can be called by its fully-qualified name
+	# as a first-class compiler
+	mkdir -p debian/gcc-multilib/usr/lib/gcc/
+	install -m 755 -p gcc-32 debian/gcc-multilib/usr/lib/gcc/gcc-32
+	install -m 755 -p gcc-64 debian/gcc-multilib/usr/lib/gcc/gcc-64
+
+	dh_link -pgcc-multilib \
+	  /usr/lib/gcc/gcc-${multilib_bits} /usr/bin/${multilib_gnu_type}-gcc
+	dh_link -pg++-multilib \
+	  /usr/lib/gcc/gcc-${multilib_bits} /usr/bin/${multilib_gnu_type}-g++
+	dh_link -pgccgo-multilib \
+	  /usr/lib/gcc/gcc-${multilib_bits} /usr/bin/${multilib_gnu_type}-gccgo
+	dh_link -pgfortran-multilib \
+	  /usr/lib/gcc/gcc-${multilib_bits} /usr/bin/${multilib_gnu_type}-gfortran
+	dh_link -pgobjc-multilib \
+	  /usr/lib/gcc/gcc-${multilib_bits} /usr/bin/${multilib_gnu_type}-gobjc
+	dh_link -pgobjc++-multilib \
+	  /usr/lib/gcc/gcc-${multilib_bits} /usr/bin/${multilib_gnu_type}-gobjc++
+  endif
+  endif
 endif  
 
 ifneq (,$(filter gdc, $(packages)))
diff --git a/gcc-32 b/gcc-32
new file mode 100755
index 0000000..19d6f5b
--- /dev/null
+++ b/gcc-32
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+# Call the appropriate compiler or preprocessor with options to build for 32-bit multilib
+
+extra_flag=-m32
+
+for i; do
+    case "$i" in
+	-m32)
+	    extra_flag=
+	    ;;
+	-m64)
+	    echo >&2 "`basename $0` called with non 32-bit multilib option $i"
+	    exit 1
+	    ;;
+    esac
+done
+
+exec ${0##*-} $extra_flag ${1+"$@"}Z
diff --git a/gcc-64 b/gcc-64
new file mode 100755
index 0000000..c31ea5c
--- /dev/null
+++ b/gcc-64
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+# Call the appropriate compiler or preprocessor with options to build for 64-bit multilib
+
+extra_flag=-m64
+
+for i; do
+    case "$i" in
+	-m64)
+	    extra_flag=
+	    ;;
+	-m32)
+	    echo >&2 "`basename $0` called with non 64-bit multilib option $i"
+	    exit 1
+	    ;;
+    esac
+done
+
+exec ${0##*-} $extra_flag ${1+"$@"}Z
-- 
1.7.9.5


Reply to: