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

Re: Proper way to initiate cross-building of a package



+++ Dima Kogan [2015-08-05 17:11 -0700]:
> Hi. I recently realized that I wasn't cross-building stuff "properly"
> and that the "proper" method isn't well-defined. 

[quick reply as I'm still on expedition, nerding between thunderstorms]

> 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? 

ish. You need to set some variables too :-)

I've tried to document corrent cross-building info for users at:
https://wiki.debian.org/CrossCompiling
(because it wasn't actually written down in any one place). That page
could use quite a lot more work, but it's a start.

My recommended rune is:
CONFIG_SITE=/etc/dpkg-cross/cross-config.<host_arch> DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -aarmhf

> 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? 

Good question. I think this needs more discussion. I agree that it's
not well-defined which tools have responsibility for setting which
things. And certainly that there is much room for at least better
docs, and maybe more automation, like what you are suggesting.

Hopefully debconf discussion can help set policy on this (pity you
will not be there in person).

> 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.

Agreed. But debhelper and dpkg-buildpackage are also supposed to be
'transparent' to local environement set-up so a bit of thought is
needed about where to set things.

Wookey
-- 
Principal hats:  Linaro, Debian, Wookware, ARM
http://wookware.org/


Reply to: