Re: The state of cross building
On Sun, Jan 31, 2016 at 12:24:29PM +0100, Timo Weingärtner wrote:
> The build log has an interesting line:
> > dpkg-architecture: warning: specified GNU system type powerpc64le-linux-gnu does not match CC system type x86_64-linux-gnu, try setting a correct CC environment variable
> And the build fails because the packages's Makefile uses $(CC) and it is not
> set correctly.
> I don't think it should be each package's responsibility to set variables
> like CC, CXX, AR, etc. Instead they should be set by dpkg-buildpackage or
> perhaps dh_auto_*.
You raise an important issue here. Whose responsibility is setting up
the CC variable?
Thus far, I have assumed that packages should not assume CC to be set.
In principle, dpkg-buildpackage could set up this variable, but policy
still mandates that e.g. ./debian/rules binary-arch should be usable.
Furthermore, quite a pile of packages support using a different compiler
(e.g. clang) by setting CC to clang before building.
Of course, this reasoning does not imply that there should be no tools
for helping with this situation and the sheer number of affected
packages makes it obvious that we need to improve tooling here.
As for your suggestion that dh_auto_* should help here, I can tell that
it already does. dh_auto_configure does pass
--build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) to configure
in a cross build setting and this very much makes autotools-based cross
builds just work. I hope that the same can be said for cmake in a not
too distant future.
Unfortunately, for Makefile based build systems we cannot simply pass CC
to the build. Exporting it as an environment variable, will not help
much as make defines CC as a builtin variable, which overrides the
environment. In the vast majority of cases, exporting is not enough. In
particular, libpam-pwdfile is an example where this is happening and
where having dpkg-buildpackage export CC does not fix the build.
What could be done is passing CC= as a command line argument to the make
invocation from dh_auto_build. Unfortunately, this invocation is also
used by autotools, where it should not pass CC=, because configure gets
that right already. Additionally, my own experience is that Makefile
based packages tend to be so old that they don't use dh_auto_build.
So I don't see an obvious way to safely introduce this CC= setting
without breaking too many builds. I very much welcome suggestions to
improve this situation as it can save considerable amount of effort here
and I already noticed that adding CC= to make invocations is becoming
repetitive for me.
Here is the debian/rules snippet, that I tend to use for fixing these
ifeq ($(origin CC),default)
CC := $(DEB_HOST_GNU_TYPE)-gcc
Then add CC=$(CC) to the recursive make invocation. I have been talking
to Guillem Jover about easing the first part, but this has not landed in
the archive yet.