Patchwork [2/2] kernel.bbclass: pass AR, NM and OBJCOPY to make

login
register
mail settings
Submitter Andreas Oberritter
Date April 15, 2011, 12:03 a.m.
Message ID <1302825782-17120-2-git-send-email-obi@opendreambox.org>
Download mbox | patch
Permalink /patch/2257/
State Accepted
Commit e1784529589c89450f45451ab99a18b28485ed5a
Headers show

Comments

Andreas Oberritter - April 15, 2011, 12:03 a.m.
- Fixes build with certain vendor-supplied Montavista kernels.
- Pass the same set of variables to every invocation of make.
- Create KERNEL_*SUFFIX, TARGET_*_KERNEL_ARCH and HOST_*_KERNEL_ARCH
  for the three variables, analogue to LD.

Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
---
 classes/kernel.bbclass |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)
Andreas Oberritter - May 16, 2011, 11:40 a.m.
Ping

On 04/15/2011 02:03 AM, Andreas Oberritter wrote:
> - Fixes build with certain vendor-supplied Montavista kernels.
> - Pass the same set of variables to every invocation of make.
> - Create KERNEL_*SUFFIX, TARGET_*_KERNEL_ARCH and HOST_*_KERNEL_ARCH
>   for the three variables, analogue to LD.
> 
> Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
> ---
>  classes/kernel.bbclass |   28 ++++++++++++++++++++++++----
>  1 files changed, 24 insertions(+), 4 deletions(-)
> 
> diff --git a/classes/kernel.bbclass b/classes/kernel.bbclass
> index bded15d..b97b725 100644
> --- a/classes/kernel.bbclass
> +++ b/classes/kernel.bbclass
> @@ -41,19 +41,39 @@ KERNEL_PRIORITY = "${@bb.data.getVar('PV',d,1).split('-')[0].split('.')[-1]}"
>  
>  KERNEL_RELEASE ?= "${KERNEL_VERSION}"
>  
> +KERNEL_ARSUFFIX ?= ""
>  KERNEL_CCSUFFIX ?= ""
>  KERNEL_LDSUFFIX ?= ""
> +KERNEL_NMSUFFIX ?= ""
> +KERNEL_OBJCOPYSUFFIX ?= ""
>  
>  # Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture
>  # specific options necessary for building the kernel and modules.
>  #FIXME: should be this: TARGET_CC_KERNEL_ARCH ?= "${TARGET_CC_ARCH}"
> +TARGET_AR_KERNEL_ARCH ?= ""
> +HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"
>  TARGET_CC_KERNEL_ARCH ?= ""
>  HOST_CC_KERNEL_ARCH ?= "${TARGET_CC_KERNEL_ARCH}"
>  TARGET_LD_KERNEL_ARCH ?= ""
>  HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}"
> +TARGET_NM_KERNEL_ARCH ?= ""
> +HOST_NM_KERNEL_ARCH ?= "${TARGET_NM_KERNEL_ARCH}"
> +TARGET_OBJCOPY_KERNEL_ARCH ?= ""
> +HOST_OBJCOPY_KERNEL_ARCH ?= "${TARGET_OBJCOPY_KERNEL_ARCH}"
>  
> +KERNEL_AR = "${AR}${KERNEL_ARSUFFIX} ${HOST_AR_KERNEL_ARCH}"
>  KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc${KERNEL_CCSUFFIX} ${HOST_CC_KERNEL_ARCH}"
>  KERNEL_LD = "${LD}${KERNEL_LDSUFFIX} ${HOST_LD_KERNEL_ARCH}"
> +KERNEL_NM = "${NM}${KERNEL_NMSUFFIX} ${HOST_NM_KERNEL_ARCH}"
> +KERNEL_OBJCOPY = "${OBJCOPY}${KERNEL_OBJCOPYSUFFIX} ${HOST_OBJCOPY_KERNEL_ARCH}"
> +
> +KERNEL_EXTRA_OEMAKE = " \
> +	AR='${KERNEL_AR}' \
> +	CC='${KERNEL_CC}' \
> +	LD='${KERNEL_LD}' \
> +	NM='${KERNEL_NM}' \
> +	OBJCOPY='${KERNEL_OBJCOPY}' \
> +"
>  
>  # Where built kernel lies in the kernel tree
>  KERNEL_OUTPUT ?= "arch/${ARCH}/boot/${KERNEL_IMAGETYPE}"
> @@ -82,17 +102,17 @@ EXTRA_OEMAKE = ""
>  
>  kernel_do_compile() {
>  	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
> -	oe_runmake include/linux/version.h CC="${KERNEL_CC}" LD="${KERNEL_LD}"
> +	oe_runmake include/linux/version.h ${KERNEL_EXTRA_OEMAKE}
>  	if [ "${KERNEL_MAJOR_VERSION}" != "2.6" ]; then
> -		oe_runmake dep CC="${KERNEL_CC}" LD="${KERNEL_LD}"
> +		oe_runmake dep ${KERNEL_EXTRA_OEMAKE}
>  	fi
> -	oe_runmake ${KERNEL_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}"
> +	oe_runmake ${KERNEL_IMAGETYPE} ${KERNEL_EXTRA_OEMAKE}
>  }
>  
>  do_compile_kernelmodules() {
>  	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
>  	if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
> -		oe_runmake modules  CC="${KERNEL_CC}" LD="${KERNEL_LD}"
> +		oe_runmake modules ${KERNEL_EXTRA_OEMAKE}
>  	else
>  		oenote "no modules to compile"
>  	fi
Phil Blundell - May 16, 2011, 11:44 a.m.
I'm mildly curious as to what Montavista can have done that requires a
custom version of ar.  But the patch looks fine to me anyway.

Acked-by: Phil Blundell <philb@gnu.org>

p.

On Mon, 2011-05-16 at 13:40 +0200, Andreas Oberritter wrote:
> Ping
> 
> On 04/15/2011 02:03 AM, Andreas Oberritter wrote:
> > - Fixes build with certain vendor-supplied Montavista kernels.
> > - Pass the same set of variables to every invocation of make.
> > - Create KERNEL_*SUFFIX, TARGET_*_KERNEL_ARCH and HOST_*_KERNEL_ARCH
> >   for the three variables, analogue to LD.
> > 
> > Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
> > ---
> >  classes/kernel.bbclass |   28 ++++++++++++++++++++++++----
> >  1 files changed, 24 insertions(+), 4 deletions(-)
> > 
> > diff --git a/classes/kernel.bbclass b/classes/kernel.bbclass
> > index bded15d..b97b725 100644
> > --- a/classes/kernel.bbclass
> > +++ b/classes/kernel.bbclass
> > @@ -41,19 +41,39 @@ KERNEL_PRIORITY = "${@bb.data.getVar('PV',d,1).split('-')[0].split('.')[-1]}"
> >  
> >  KERNEL_RELEASE ?= "${KERNEL_VERSION}"
> >  
> > +KERNEL_ARSUFFIX ?= ""
> >  KERNEL_CCSUFFIX ?= ""
> >  KERNEL_LDSUFFIX ?= ""
> > +KERNEL_NMSUFFIX ?= ""
> > +KERNEL_OBJCOPYSUFFIX ?= ""
> >  
> >  # Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture
> >  # specific options necessary for building the kernel and modules.
> >  #FIXME: should be this: TARGET_CC_KERNEL_ARCH ?= "${TARGET_CC_ARCH}"
> > +TARGET_AR_KERNEL_ARCH ?= ""
> > +HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"
> >  TARGET_CC_KERNEL_ARCH ?= ""
> >  HOST_CC_KERNEL_ARCH ?= "${TARGET_CC_KERNEL_ARCH}"
> >  TARGET_LD_KERNEL_ARCH ?= ""
> >  HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}"
> > +TARGET_NM_KERNEL_ARCH ?= ""
> > +HOST_NM_KERNEL_ARCH ?= "${TARGET_NM_KERNEL_ARCH}"
> > +TARGET_OBJCOPY_KERNEL_ARCH ?= ""
> > +HOST_OBJCOPY_KERNEL_ARCH ?= "${TARGET_OBJCOPY_KERNEL_ARCH}"
> >  
> > +KERNEL_AR = "${AR}${KERNEL_ARSUFFIX} ${HOST_AR_KERNEL_ARCH}"
> >  KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc${KERNEL_CCSUFFIX} ${HOST_CC_KERNEL_ARCH}"
> >  KERNEL_LD = "${LD}${KERNEL_LDSUFFIX} ${HOST_LD_KERNEL_ARCH}"
> > +KERNEL_NM = "${NM}${KERNEL_NMSUFFIX} ${HOST_NM_KERNEL_ARCH}"
> > +KERNEL_OBJCOPY = "${OBJCOPY}${KERNEL_OBJCOPYSUFFIX} ${HOST_OBJCOPY_KERNEL_ARCH}"
> > +
> > +KERNEL_EXTRA_OEMAKE = " \
> > +	AR='${KERNEL_AR}' \
> > +	CC='${KERNEL_CC}' \
> > +	LD='${KERNEL_LD}' \
> > +	NM='${KERNEL_NM}' \
> > +	OBJCOPY='${KERNEL_OBJCOPY}' \
> > +"
> >  
> >  # Where built kernel lies in the kernel tree
> >  KERNEL_OUTPUT ?= "arch/${ARCH}/boot/${KERNEL_IMAGETYPE}"
> > @@ -82,17 +102,17 @@ EXTRA_OEMAKE = ""
> >  
> >  kernel_do_compile() {
> >  	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
> > -	oe_runmake include/linux/version.h CC="${KERNEL_CC}" LD="${KERNEL_LD}"
> > +	oe_runmake include/linux/version.h ${KERNEL_EXTRA_OEMAKE}
> >  	if [ "${KERNEL_MAJOR_VERSION}" != "2.6" ]; then
> > -		oe_runmake dep CC="${KERNEL_CC}" LD="${KERNEL_LD}"
> > +		oe_runmake dep ${KERNEL_EXTRA_OEMAKE}
> >  	fi
> > -	oe_runmake ${KERNEL_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}"
> > +	oe_runmake ${KERNEL_IMAGETYPE} ${KERNEL_EXTRA_OEMAKE}
> >  }
> >  
> >  do_compile_kernelmodules() {
> >  	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
> >  	if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
> > -		oe_runmake modules  CC="${KERNEL_CC}" LD="${KERNEL_LD}"
> > +		oe_runmake modules ${KERNEL_EXTRA_OEMAKE}
> >  	else
> >  		oenote "no modules to compile"
> >  	fi
> 
> 
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel
Andreas Oberritter - May 16, 2011, 12:14 p.m.
On 05/16/2011 01:44 PM, Phil Blundell wrote:
> I'm mildly curious as to what Montavista can have done that requires a
> custom version of ar.  But the patch looks fine to me anyway.

I don't know whether this change came from Montavista or from the vendor
supplying the kernel sources. Anyway, someone changed CROSS_COMPILE to
override the environment, thus using a prefix different from the
toolchain built by OE.

CROSS_COMPILE   = $(shell if [ -f .mvl_cross_compile ]; then \
                                  cat .mvl_cross_compile; \
                          fi)

With the patch applied, the variable CROSS_COMPILE isn't used anymore,
because all cross-tools are specified on the command line in the same
manner.

Another way to solve this problem could have been to set CROSS_COMPILE
on the command line instead of in the environment. I haven't tried that.
I could create an updated patch if this was preferred.

Regards,
Andreas

Patch

diff --git a/classes/kernel.bbclass b/classes/kernel.bbclass
index bded15d..b97b725 100644
--- a/classes/kernel.bbclass
+++ b/classes/kernel.bbclass
@@ -41,19 +41,39 @@  KERNEL_PRIORITY = "${@bb.data.getVar('PV',d,1).split('-')[0].split('.')[-1]}"
 
 KERNEL_RELEASE ?= "${KERNEL_VERSION}"
 
+KERNEL_ARSUFFIX ?= ""
 KERNEL_CCSUFFIX ?= ""
 KERNEL_LDSUFFIX ?= ""
+KERNEL_NMSUFFIX ?= ""
+KERNEL_OBJCOPYSUFFIX ?= ""
 
 # Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture
 # specific options necessary for building the kernel and modules.
 #FIXME: should be this: TARGET_CC_KERNEL_ARCH ?= "${TARGET_CC_ARCH}"
+TARGET_AR_KERNEL_ARCH ?= ""
+HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"
 TARGET_CC_KERNEL_ARCH ?= ""
 HOST_CC_KERNEL_ARCH ?= "${TARGET_CC_KERNEL_ARCH}"
 TARGET_LD_KERNEL_ARCH ?= ""
 HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}"
+TARGET_NM_KERNEL_ARCH ?= ""
+HOST_NM_KERNEL_ARCH ?= "${TARGET_NM_KERNEL_ARCH}"
+TARGET_OBJCOPY_KERNEL_ARCH ?= ""
+HOST_OBJCOPY_KERNEL_ARCH ?= "${TARGET_OBJCOPY_KERNEL_ARCH}"
 
+KERNEL_AR = "${AR}${KERNEL_ARSUFFIX} ${HOST_AR_KERNEL_ARCH}"
 KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc${KERNEL_CCSUFFIX} ${HOST_CC_KERNEL_ARCH}"
 KERNEL_LD = "${LD}${KERNEL_LDSUFFIX} ${HOST_LD_KERNEL_ARCH}"
+KERNEL_NM = "${NM}${KERNEL_NMSUFFIX} ${HOST_NM_KERNEL_ARCH}"
+KERNEL_OBJCOPY = "${OBJCOPY}${KERNEL_OBJCOPYSUFFIX} ${HOST_OBJCOPY_KERNEL_ARCH}"
+
+KERNEL_EXTRA_OEMAKE = " \
+	AR='${KERNEL_AR}' \
+	CC='${KERNEL_CC}' \
+	LD='${KERNEL_LD}' \
+	NM='${KERNEL_NM}' \
+	OBJCOPY='${KERNEL_OBJCOPY}' \
+"
 
 # Where built kernel lies in the kernel tree
 KERNEL_OUTPUT ?= "arch/${ARCH}/boot/${KERNEL_IMAGETYPE}"
@@ -82,17 +102,17 @@  EXTRA_OEMAKE = ""
 
 kernel_do_compile() {
 	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
-	oe_runmake include/linux/version.h CC="${KERNEL_CC}" LD="${KERNEL_LD}"
+	oe_runmake include/linux/version.h ${KERNEL_EXTRA_OEMAKE}
 	if [ "${KERNEL_MAJOR_VERSION}" != "2.6" ]; then
-		oe_runmake dep CC="${KERNEL_CC}" LD="${KERNEL_LD}"
+		oe_runmake dep ${KERNEL_EXTRA_OEMAKE}
 	fi
-	oe_runmake ${KERNEL_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}"
+	oe_runmake ${KERNEL_IMAGETYPE} ${KERNEL_EXTRA_OEMAKE}
 }
 
 do_compile_kernelmodules() {
 	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
 	if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
-		oe_runmake modules  CC="${KERNEL_CC}" LD="${KERNEL_LD}"
+		oe_runmake modules ${KERNEL_EXTRA_OEMAKE}
 	else
 		oenote "no modules to compile"
 	fi