Patchwork Cross compile rules update

login
register
mail settings
Submitter Sebastien Jan
Date Oct. 11, 2010, 2:21 p.m.
Message ID <AANLkTimx+dsDy=i6esjJiP7FMSLX1x2aESsA=KgoF9c-@mail.gmail.com>
Download mbox | patch
Permalink /patch/67427/
State Accepted
Delegated to: Tim Gardner
Headers show

Comments

Sebastien Jan - Oct. 11, 2010, 2:21 p.m.
Hi Tim,

On Thu, Sep 30, 2010 at 7:46 PM, Tim Gardner <tim.gardner@canonical.com> wrote:
> On 09/30/2010 09:41 AM, Andy Whitcroft wrote:
>>
>> I am slightly concerned that this one dh_ control needs the arch and
>> none of the others do.  Might we be better off exporting them at the
>> time they are defined; pretty sure there is a way to say that you want
>> that when you set the values.
>>
>> Otherwise it does look saneish.  It is unfortuanate you need to zap the
>> tools unconditionally, perhaps we should leave that to the caller.
>>
>> -apw
>
> It turns out the dh_gencontrol line changes were superfluous. It didn't work
> anyways with the 'fakeroot debian/rules binary arch=armel' invocation. It
> only works using 'dpkg-buildpackage -aarmel' which sets the internal notion
> of HOST arch that dh_gencontrol uses.
>
> Loic - I've made the CROSS_COMPILE and do_tools changes as requested.

I am testing the ti-omap4 branch, and cannot cross-compile anymore
with CS since the introduction of this patch. My CROSS_COMPILE
variable seems ignored (using CROSS_COMPILE=arm-none-linux-gnueabi-
dpkg-architecture -B -aarmel, or fakeroot debian/rules).

I was able to cross-compile with the following hack:

Am I using a wrong build command our could there be something wrong
with the makefile?

Thanks,
Sebastien
Loïc Minier - Oct. 11, 2010, 2:51 p.m.
On Mon, Oct 11, 2010, Jan, Sebastien wrote:
> I was able to cross-compile with the following hack:
> diff --git a/debian/rules.d/0-common-vars.mk b/debian/rules.d/0-common-vars.mk
> index 66d3900..b4d7a8a 100644
> --- a/debian/rules.d/0-common-vars.mk
> +++ b/debian/rules.d/0-common-vars.mk
> @@ -106,9 +106,13 @@ endif
>  # an x86'en schroot. This is the only way to build all of the packages
>  # (except for tools).
>  #
> +ifneq ($(CROSS_COMPILE),)
> +       CROSS_COMPILE := CROSS_COMPILE=$(CROSS_COMPILE)
> +else
>  ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
>         CROSS_COMPILE ?= CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
>  endif
> +endif

 Oh right, the issue is probably that you pass the right CROSS_COMPILE
 with the value "some-cross-prefix-" that the downstream kernel build
 expects, but the kernel debian/rules machinery expects this variable to
 contain "CROSS_COMPILE=some-cross-prefix-", and not just
 "some-cross-prefix-".

 A nicer fix would be to rename the CROSS_COMPILE=foo argument to the
 kernel build differently, or to only store its value in the variable.

 That is, either:
    ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
    CROSS_COMPILE_ARG ?= CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
    endif
    [...]
    $(MAKE) $(CROSS_COMPILE_ARG)

 or, nicer:
    ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
    CROSS_COMPILE ?= $(DEB_HOST_GNU_TYPE)-
    endif
    [...]
    $(MAKE) CROSS_COMPILE=$(CROSS_COMPILE)

 the latter will result in make being called with "CROSS_COMPILE=" in
 native builds, which should be just fine, but if you really want to
 avoid it you could use a $(if ) construct on the make invocation.

    Cheers,
Sebastien Jan - Oct. 11, 2010, 3:50 p.m.
On Mon, Oct 11, 2010 at 4:51 PM, Loïc Minier <loic.minier@ubuntu.com> wrote:
> On Mon, Oct 11, 2010, Jan, Sebastien wrote:
>> I was able to cross-compile with the following hack:
>> diff --git a/debian/rules.d/0-common-vars.mk b/debian/rules.d/0-common-vars.mk
>> index 66d3900..b4d7a8a 100644
>> --- a/debian/rules.d/0-common-vars.mk
>> +++ b/debian/rules.d/0-common-vars.mk
>> @@ -106,9 +106,13 @@ endif
>>  # an x86'en schroot. This is the only way to build all of the packages
>>  # (except for tools).
>>  #
>> +ifneq ($(CROSS_COMPILE),)
>> +       CROSS_COMPILE := CROSS_COMPILE=$(CROSS_COMPILE)
>> +else
>>  ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
>>         CROSS_COMPILE ?= CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
>>  endif
>> +endif
>
>  Oh right, the issue is probably that you pass the right CROSS_COMPILE
>  with the value "some-cross-prefix-" that the downstream kernel build
>  expects, but the kernel debian/rules machinery expects this variable to
>  contain "CROSS_COMPILE=some-cross-prefix-", and not just
>  "some-cross-prefix-".

Right, the following command runs well:
CROSS_COMPILE="CROSS_COMPILE=arm-none-linux-gnueabi-"
dpkg-buildpackage -B -aarmel

>  A nicer fix would be to rename the CROSS_COMPILE=foo argument to the
>  kernel build differently, or to only store its value in the variable.
>
>  That is, either:
>    ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
>    CROSS_COMPILE_ARG ?= CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
>    endif
>    [...]
>    $(MAKE) $(CROSS_COMPILE_ARG)
>
>  or, nicer:
>    ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
>    CROSS_COMPILE ?= $(DEB_HOST_GNU_TYPE)-
>    endif
>    [...]
>    $(MAKE) CROSS_COMPILE=$(CROSS_COMPILE)
>
>  the latter will result in make being called with "CROSS_COMPILE=" in
>  native builds, which should be just fine, but if you really want to
>  avoid it you could use a $(if ) construct on the make invocation.

Either ways you expect to retrieve the cross-compiler name through the
DEB_HOST_GNU_TYPE variable? In my case I always get
DEB_HOST_GNU_TYPE=arm-linux-gnueabi (that's the output of
dpkg-architecture). Is this expected?
If yes, I don't understand how my cross-compiler (CS here) gets passed
to make. Your two above proposals would override what I could write on
the command line? (hence my 1st patch)
Loïc Minier - Oct. 11, 2010, 4:30 p.m.
On Mon, Oct 11, 2010, Jan, Sebastien wrote:
> Either ways you expect to retrieve the cross-compiler name through the
> DEB_HOST_GNU_TYPE variable? In my case I always get
> DEB_HOST_GNU_TYPE=arm-linux-gnueabi (that's the output of
> dpkg-architecture). Is this expected?
> If yes, I don't understand how my cross-compiler (CS here) gets passed
> to make. Your two above proposals would override what I could write on
> the command line? (hence my 1st patch)

 So for Debian/Ubuntu-style cross-builds (dpkg-buildpackage -aarmel), we
 can assume that the cross-toolchain is using the $(DEB_HOST_GNU_TYPE)-
 prefix, so $(DEB_HOST_GNU_TYPE)-gcc, -ld etc. are available.

 It's however convenient for some specific packages, like the kernel or
 u-boot or x-loader, to be able to override the standard
 cross-compilation toolchain with a personal one.  In your case, the
 arm-none-linux-gnueabi- prefix or something like that.

 So the intent was to set CROSS_COMPILE to $(DEB_HOST_GNU_TYPE)- by
 default (standard Debian/Ubuntu cross builds) unless if CROSS_COMPILE
 is set (in which case, just use what's in CROSS_COMPILE instead).

 Note the ?= in my proposals which means that CROSS_COMPILE is only set
 if it wasn't set in the environment.

Patch

diff --git a/debian/rules.d/0-common-vars.mk b/debian/rules.d/0-common-vars.mk
index 66d3900..b4d7a8a 100644
--- a/debian/rules.d/0-common-vars.mk
+++ b/debian/rules.d/0-common-vars.mk
@@ -106,9 +106,13 @@  endif
 # an x86'en schroot. This is the only way to build all of the packages
 # (except for tools).
 #
+ifneq ($(CROSS_COMPILE),)
+       CROSS_COMPILE := CROSS_COMPILE=$(CROSS_COMPILE)
+else
 ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
        CROSS_COMPILE ?= CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
 endif
+endif

 abidir         := $(CURDIR)/$(DEBIAN)/abi/$(release)-$(revision)/$(arch)
 prev_abidir    := $(CURDIR)/$(DEBIAN)/abi/$(release)-$(prev_revision)/$(arch)