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

Re: Details about CC env var and dpkgbuildpackage -a

Hi Dima,

On Tue, Aug 22, 2017 at 06:24:33AM -0700, Dima Kogan wrote:
> I recently sent some patches to the lapack maintainer to get that
> package to be cross-buildable:
>   http://bugs.debian.org/770290

Cool! Looks like we are working on similar things. #871967 And I'm
looking forward to libblas-common to go away (which was supposed to
happen for stretch already).

Are there particular packages you are interested in?

I count some 1300 successfully cross buildable packages and 700 packages
waiting for maintainers to apply patches here. I wonder how we get that
latter number down.

>   But what happens when these two conflict? I.e. if on an amd64 box I
>   say
>   CC=gcc dpkg-buildpackage -armhf

This will misbuild. In the best case, your build fails.

>   I think the right answer is for dpkg-buildpackage to barf, which it
>   doesn't. This is a bug (or missing feature) in dpkg-buildpackage, yes?

I don't think there is a way for dpkg-buildpackage to check this. For
instance, you could be using /opt/cross-toolchain-for-xxxx/bin/gcc (not
recommended). dpkg-buildpackage has no reasonable way to check whether
the compiler matches the host architecture. It simply cannot. See

> - What about fortran? Similar conflict can happen with
>   F77=arm-linux-gnueabihf-gfortran CC=gcc dpkg-buildpackage
>   dpkg-buildpackage should complain?

I believe the responsibility for these variables is with the builder.
The build must cope with the absence of CC and F77 and use sensible

> For lapack, I'm going to put this into debian/rules (unless somebody
> here tells me otherwise):
>   # if we're cross-building and CC isn't explicitly set, set it to the
>   # cross-compiler
>   ifeq ($(origin CC),default)
>   CC := /usr/bin/$(DEB_HOST_GNU_TYPE)-cc
>   endif
>   endif

I think you can do without the outer ifneq. Since CC is only set when
there is no CC on the environment, and the gcc package always
instantiates symlinks for the native triplet, always using a
triplet-prefixed compiler is safe. Thus that's what I do, when I submit

> The reasoning is that the build system uses $(CC) to allow the user to
> ask for clang via the environment. So we need to use CC too, but if the
> user invoked
>   dpkg-buildpackage -aarmhf
> then I need to set CC to the cross compiler. Is that invocation correct?
> Is there some less boilerplaty way to get this functionality?

I've been asking Guillem Jover to add /usr/share/dpkg/toolchain.mk for a
while now. It is supposed to set up CC, CXX, PKG_CONFIG and a few others
without exporting them. Looking forward to see that happen.

Often enough passing a cross CC to a Makefile is as simple as
dh_auto_build though. :)


Reply to: