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

Proper way to initiate cross-building of a package



Hi. I recently realized that I wasn't cross-building stuff "properly"
and that the "proper" method isn't well-defined. This email is a
question and a proposal. To be clear, this isn't about building
toolchains, but about using a cross toolchain to build normal packages.

Previously I'd cross-build stuff with

 CC=arm-linux-gnueabihf-gcc dpkg-buildpackage

This mostly works, but if you try to swap sbuild for dpkg-buildpackage,
then the CC variable doesn't make it down far enough, and this fails.

Instead of that command, one could instead issue

 dpkg-buildpackage -aarmhf

This type of invocation works for dpkg-buildpackage and sbuild, but I
find that the compiler variables (CC and such) then don't get set
automatically, and the build fails, unless the debian/rules explicitly
handles cross-building.

First of all, this latter invocation is the "correct" one, yes? If so,
then I think it'd be great if the compiler variables were set without
explicit support in debian/rules. Most packages use debhelper, so that
seems like a logical place to put that. I implemented a very simple
change to debhelper that does this:

  http://anonscm.debian.org/cgit/users/dkogan-guest/experimental/debhelper.git/commit/?h=auto_cross_cc&id=f58f39dacb46759fa8c02eb7fa5cebe0a9dcc955

Here whenever we look at 'dpkg-buildflags' to set the compiler flags we
ALSO set the compiler variables if (we are cross building AND these
variables aren't yet set). This patch works for trivial debhelper-based
debian/rules, which look like this:

-----------------------
%:
	dh $@
-----------------------

This patch touches CC and CXX only, and would need to be expanded to
cover more of the tools. Is this a reasonable way to go? Looking around,
it isn't obvious what the concrete plan is and how this should be
handled otherwise. Not requiring every package to put stuff into their
debian/rules to support cross-building is desirable, and that's the main
advantage that I see of putting this logic here.


Reply to: