dpkg-cross proposals (was: How to handle cross compiling source packages?)
- To: debian-embedded@lists.debian.org
- Cc: "Nikita V. Youshchenko" <yoush@debian.org>, Ron <ron@debian.org>
- Subject: dpkg-cross proposals (was: How to handle cross compiling source packages?)
- From: Volker Grabsch <vog@notjusthosting.com>
- Date: Wed, 12 Apr 2006 21:50:46 +0200
- Message-id: <20060412195045.GA12696@flap>
- In-reply-to: <20060412001740.GA24403@flap>
- References: <200603301105.49459@zigzag.lvk.cs.msu.su> <20060412001740.GA24403@flap>
Dear dpkg-cross Developers,
Here are some proposals to fix the problems I mentioned my last mail.
1. small bugfix in DEB_* environment variables
----------------------------------------------
While stepping through the sources, I found a nasty typo.
It causes the DPKG_* environment variables not to be set
correctly.
This is fixed by:
patch-dpkgcross-fix-DEB-variables.diff
2. use /etc/dpkg-cross/cross-config.$(DEB_HOST_ARCH_OS)
-------------------------------------------------------
The files cross-config.* contain a suffix for each architecture.
Some suffixes are CPU type, but most are OS types.
I don't think it was initially indenteded to use $arch or
$(DEB_HOST_ARCH), e.g. "hurd-i386" as suffix. Looking at the
documentation and source comments, it seems to me that the authors
meant $(DEB_HOST_ARCH_OS) instead, e.g. "hurd".
If I got it right, the system is intended to do the following:
dpkg-cross.pl includes the cross-config.OS which includes
the cross-config.common which includes the cross-config.CPU
Otherwise, there would have to exist a file cross-config.hurd-i386
which of course isn't there.
This is fixed by:
patch-dpkgcross-use-DEB_HOST_ARCH_OS.diff
3. use dpkg-architecture instead of %archtable
----------------------------------------------
dpkg-cross uses an internal table %archtable for mapping $arch
to the GNU type. (e.g. i386 -> i486-linux-gnu)
However, dpkg-architecture does the job much better.
This has already been marked in the dpkg-cross.pl:
# FIXME: should use dpkg-architecture here
But there's a subtle circular dependency. When cross compiling
a package using "dpkg-buildpackage -a...", it results in an
infinite recursion. It was hard to analyze it, here's a simplified
summary of my research:
* dpkg-buildpackage sets gcc -> gccross
* dpkg-buildpackage calls (indirectly) gcc
Loop:
* gcc has been mapped to gccross
* gccross includes dpkg-cross.pl
* dpkg-cross.pl calls dpkg-architecture
* dpkg-architecture calls gcc
* gcc has been mapped to gccross
* ...
This is really stupid. dpkg-architecture rather doesn't need
to call "gcc", because dpkg-cross.pl doesn't asks for the
current architecture.
Since dpkg-architecture only needs programs in /usr/bin, that
problem can be solved by setting PATH=/usr/bin before calling
dpkg-architecture.
This is fixed by:
patch-dpkgcross-use-dpkg-architecture.diff
4. modifying the PATH correctly
-------------------------------
dpkg-cross.pl changes the PATH:
$ENV{'PATH'} = "/usr/share/dpkg-cross:$ENV{PATH}:$crossbin";
However, when there's e.g. SDL installed, the sdl-config of /usr/bin
would be used, instead of the correct $crossbin/sdl-config. So the
$crossbin should take precendence:
$ENV{'PATH'} = "/usr/share/dpkg-cross:$crossbin:$ENV{PATH}";
In addition, the "strip" wrapper doesn't work for me, and the
wrong "ranlib" is called. (which isn't patform independent!)
So the only way I currently get it working is by putting $crossbin
at the first place of PATH:
$ENV{'PATH'} = "$crossbin:/usr/share/dpkg-cross:$ENV{PATH}";
However, on the other hand, the sources contain a comment which
states that they "append $crossbin, so that cross binaries can
be found, but native stuff still has precedence (if a package
wants to compile with 'gcc' a build tool that will be executed,
for example)."
This is a serious problem. Maybe I could bugfix the wrappers and
include "ar" and "ranlib" in %std_tools. This way cross compiling
would generally work with $crossbin as the last PATH entry. But
what's about sdl-config, pkg-config, etc.?
I don't supply a patch, because I'm unsure how to solve that
problem. Does anyone use dpkg-cross to build applications that
use glib-config, gtk-config, sdl-config or similar?
Greets,
Volker
--
Volker Grabsch
---<<(())>>---
Administrator
NotJustHosting GbR
Wed Apr 12 13:02:17 CEST 2006 Volker Grabsch <vog@notjusthosting.com>
* fix-DEB-variables
diff -rN -u old-dpkg-cross/dpkg-cross-1.26/dpkg-cross.pl new-dpkg-cross/dpkg-cross-1.26/dpkg-cross.pl
--- old-dpkg-cross/dpkg-cross-1.26/dpkg-cross.pl 2006-04-12 13:04:21.000000000 +0200
+++ new-dpkg-cross/dpkg-cross-1.26/dpkg-cross.pl 2006-04-12 13:04:21.000000000 +0200
@@ -459,7 +459,7 @@
# Set `dpkg-architecture' environment veriables.
foreach $var_ qw(DEB_HOST_ARCH DEB_HOST_ARCH_OS DEB_HOST_ARCH_CPU
DEB_HOST_GNU_CPU DEB_HOST_GNU_SYSTEM DEB_HOST_GNU_TYPE) {
- chomp ($tmp = `dpkg-architecture -a$arch -q$var_ 2>/dev/null`);
+ chomp ($tmp_ = `dpkg-architecture -a$arch -q$var_ 2>/dev/null`);
$ENV{$var_} = $tmp_;
}
Wed Apr 12 13:08:41 CEST 2006 Volker Grabsch <vog@notjusthosting.com>
* use-DEB_HOST_ARCH_OS
diff -rN -u old-dpkg-cross/dpkg-cross-1.26/dpkg-cross.pl new-dpkg-cross/dpkg-cross-1.26/dpkg-cross.pl
--- old-dpkg-cross/dpkg-cross-1.26/dpkg-cross.pl 2006-04-12 14:19:24.000000000 +0200
+++ new-dpkg-cross/dpkg-cross-1.26/dpkg-cross.pl 2006-04-12 14:19:24.000000000 +0200
@@ -475,9 +475,9 @@
# Set USRLIBDIR to $(CROSSLIB), for imake-generated Makefiles..
$makeflags_{'USRLIBDIR'} = $crosslib;
- # Set CONFIG_SITE to /etc/dpkg-cross/cross-config.``$arch'', for
+ # Set CONFIG_SITE to /etc/dpkg-cross/cross-config.``$(DEB_HOST_ARCH_OS)'', for
# packages using GNU autoconf configure scripts.
- $makeflags_{'CONFIG_SITE'} = "/etc/dpkg-cross/cross-config.$arch";
+ $makeflags_{'CONFIG_SITE'} = "/etc/dpkg-cross/cross-config.$ENV{'DEB_HOST_ARCH_OS'}";
# Set standard variables for compilers and binutils.
foreach $var_ ( keys %std_tools ) {
Wed Apr 12 19:34:14 CEST 2006 Volker Grabsch <vog@notjusthosting.com>
* use-dpkg-architecture
diff -rN -u old-dpkg-cross/dpkg-cross-1.26/dpkg-cross.pl new-dpkg-cross/dpkg-cross-1.26/dpkg-cross.pl
--- old-dpkg-cross/dpkg-cross-1.26/dpkg-cross.pl 2006-04-12 19:35:22.000000000 +0200
+++ new-dpkg-cross/dpkg-cross-1.26/dpkg-cross.pl 2006-04-12 19:35:22.000000000 +0200
@@ -261,7 +261,13 @@
# Set ``$arch'' to defaults if not already specified.
$arch = get_architecture();
die "$progname: Architecture is not specified.\n" unless ($arch);
- $deb_host_gnu_type = $archtable{$arch}; # FIXME: should use dpkg-architecture here
+
+ # Get the DEB_HOST_GNU_TYPE from dpkg-architecture.
+ # The PATH is set to /usr/bin to avoid infinite recursion.
+ # This may be caused by dpkg-architecture calling gccross,
+ # thinking it calls gcc. So we ensure that dpkg-architecture
+ # to always calls /usr/bin/gcc.
+ chomp ($deb_host_gnu_type = `PATH=/usr/bin dpkg-architecture -a$arch -qDEB_HOST_GNU_TYPE 2>/dev/null`);
# Finalize, no subst possible crossbase.
$crossbase ||= "/usr";
Reply to: