Message ID | AANLkTimx+dsDy=i6esjJiP7FMSLX1x2aESsA=KgoF9c-@mail.gmail.com |
---|---|
State | Accepted |
Delegated to: | Tim Gardner |
Headers | show |
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,
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)
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.
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)