Patchwork [V2,1/3] kernel.bbclass, module-base.bbclass: Use CC to form KERNEL_CC

login
register
mail settings
Submitter Khem Raj
Date Sept. 12, 2012, 5:59 a.m.
Message ID <1347429555-32159-1-git-send-email-raj.khem@gmail.com>
Download mbox | patch
Permalink /patch/36399/
State New
Headers show

Comments

Khem Raj - Sept. 12, 2012, 5:59 a.m.
kernel compiler is not special and we currently have it so
we want to pass -march and -mtune options as CFLAGS to kernel
build so that compiler picks the right subarch flags when
compiling assembly files in particular. Otherwise defaults
are chosen which may not be right in many case e.g. when
compiling kernel for collie machine we should use arch=armv4
but it uses toolchain/as defaults which is armv5te

in some case e.g. thumb1 we know that kernel can not be compiled
in thumb1 mode so we can provide that information e.g. -marm
option through KERNEL_HOST_CC_ARCH variable as we do now

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/classes/kernel-arch.bbclass |   13 +++++++++++++
 meta/classes/kernel.bbclass      |   16 +---------------
 meta/classes/module-base.bbclass |   16 ----------------
 3 files changed, 14 insertions(+), 31 deletions(-)
Phil Blundell - Sept. 12, 2012, 6:32 a.m.
On Tue, 2012-09-11 at 22:59 -0700, Khem Raj wrote:
> kernel compiler is not special and we currently have it so
> we want to pass -march and -mtune options as CFLAGS to kernel
> build so that compiler picks the right subarch flags when
> compiling assembly files in particular.

Historically, the kernel compiler has indeed been special: there have
been some machines where, due to bugs in the kernel or the compiler or
both, we need to use a different version of the compiler for the kernel
than we use for userspace.  The most famous example of this were the old
ARM kernels back in the day which needed gcc-2.95 long after everyone
else had stopped using it, but I think there might be a few cases where
the same situation obtains even today.

If you remove ${KERNEL_CCSUFFIX} then we will lose the ability to do
that (easily).  I'm not necessarily opposed to such a change but I think
it does need to be justified with clear benefits.

p.
Khem Raj - Sept. 12, 2012, 7:49 a.m.
On Tue, Sep 11, 2012 at 11:32 PM, Phil Blundell <philb@gnu.org> wrote:
> On Tue, 2012-09-11 at 22:59 -0700, Khem Raj wrote:
>> kernel compiler is not special and we currently have it so
>> we want to pass -march and -mtune options as CFLAGS to kernel
>> build so that compiler picks the right subarch flags when
>> compiling assembly files in particular.
>
> Historically, the kernel compiler has indeed been special: there have
> been some machines where, due to bugs in the kernel or the compiler or
> both, we need to use a different version of the compiler for the kernel
> than we use for userspace.  The most famous example of this were the old
> ARM kernels back in the day which needed gcc-2.95 long after everyone
> else had stopped using it, but I think there might be a few cases where
> the same situation obtains even today.

I agree with history but we have moved away from 2.9x for long.
moreover v1 of this patch has been posted for weeks no one raised a
concern which I take that such cases are not there anymore with
OE-Core

>
> If you remove ${KERNEL_CCSUFFIX} then we will lose the ability to do
> that (easily).  I'm not necessarily opposed to such a change but I think
> it does need to be justified with clear benefits.
>

again if there is a usecase with OE-Core of such a kind. I will be
happy to deal with it no one has shown me one.

> p.
>
>
Koen Kooi - Sept. 13, 2012, 6:02 p.m.
Op 12 sep. 2012, om 09:49 heeft Khem Raj <raj.khem@gmail.com> het volgende geschreven:

> On Tue, Sep 11, 2012 at 11:32 PM, Phil Blundell <philb@gnu.org> wrote:
>> On Tue, 2012-09-11 at 22:59 -0700, Khem Raj wrote:
>>> kernel compiler is not special and we currently have it so
>>> we want to pass -march and -mtune options as CFLAGS to kernel
>>> build so that compiler picks the right subarch flags when
>>> compiling assembly files in particular.
>> 
>> Historically, the kernel compiler has indeed been special: there have
>> been some machines where, due to bugs in the kernel or the compiler or
>> both, we need to use a different version of the compiler for the kernel
>> than we use for userspace.  The most famous example of this were the old
>> ARM kernels back in the day which needed gcc-2.95 long after everyone
>> else had stopped using it, but I think there might be a few cases where
>> the same situation obtains even today.
> 
> I agree with history but we have moved away from 2.9x for long.
> moreover v1 of this patch has been posted for weeks no one raised a
> concern which I take that such cases are not there anymore with
> OE-Core
> 
>> 
>> If you remove ${KERNEL_CCSUFFIX} then we will lose the ability to do
>> that (easily).  I'm not necessarily opposed to such a change but I think
>> it does need to be justified with clear benefits.
>> 
> 
> again if there is a usecase with OE-Core of such a kind. I will be
> happy to deal with it no one has shown me one.

The archos vendor kernels only work when built with CSL 2007, a common problem with TI kernels from that era

Patch

diff --git a/meta/classes/kernel-arch.bbclass b/meta/classes/kernel-arch.bbclass
index 6446504..95a40f2 100644
--- a/meta/classes/kernel-arch.bbclass
+++ b/meta/classes/kernel-arch.bbclass
@@ -42,3 +42,16 @@  def map_uboot_arch(a, d):
 
 export UBOOT_ARCH = "${@map_uboot_arch(d.getVar('ARCH', True), d)}"
 
+# Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture
+# specific options necessary for building the kernel and modules.
+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_AR_KERNEL_ARCH ?= ""
+HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"
+
+KERNEL_CC = "${CC} ${HOST_CC_KERNEL_ARCH}"
+KERNEL_LD = "${LD} ${HOST_LD_KERNEL_ARCH}"
+KERNEL_AR = "${AR} ${HOST_AR_KERNEL_ARCH}"
+
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index fdef1be..bcb6bd5 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -1,7 +1,7 @@ 
 inherit linux-kernel-base module_strip
 
 PROVIDES += "virtual/kernel"
-DEPENDS += "virtual/${TARGET_PREFIX}gcc kmod-native virtual/${TARGET_PREFIX}gcc${KERNEL_CCSUFFIX} update-modules"
+DEPENDS += "virtual/${TARGET_PREFIX}gcc kmod-native update-modules"
 
 # we include gcc above, we dont need virtual/libc
 INHIBIT_DEFAULT_DEPS = "1"
@@ -37,20 +37,6 @@  KERNEL_PRIORITY ?= "${@int(d.getVar('PV',1).split('-')[0].split('+')[0].split('.
 
 KERNEL_RELEASE ?= "${KERNEL_VERSION}"
 
-KERNEL_CCSUFFIX ?= ""
-KERNEL_LDSUFFIX ?= ""
-
-# 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_CC_KERNEL_ARCH ?= ""
-HOST_CC_KERNEL_ARCH ?= "${TARGET_CC_KERNEL_ARCH}"
-TARGET_LD_KERNEL_ARCH ?= ""
-HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}"
-
-KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc${KERNEL_CCSUFFIX} ${HOST_CC_KERNEL_ARCH}${TOOLCHAIN_OPTIONS}"
-KERNEL_LD = "${HOST_PREFIX}ld${KERNEL_LDSUFFIX} ${HOST_LD_KERNEL_ARCH}${TOOLCHAIN_OPTIONS}"
-
 # Where built kernel lies in the kernel tree
 KERNEL_OUTPUT ?= "arch/${ARCH}/boot/${KERNEL_IMAGETYPE}"
 KERNEL_IMAGEDEST = "boot"
diff --git a/meta/classes/module-base.bbclass b/meta/classes/module-base.bbclass
index 9379bf8..f4ec2d4 100644
--- a/meta/classes/module-base.bbclass
+++ b/meta/classes/module-base.bbclass
@@ -7,22 +7,6 @@  export CROSS_COMPILE = "${TARGET_PREFIX}"
 
 export KERNEL_VERSION = "${@base_read_file('${STAGING_KERNEL_DIR}/kernel-abiversion')}"
 KERNEL_OBJECT_SUFFIX = ".ko"
-KERNEL_CCSUFFIX = "${@base_read_file('${STAGING_KERNEL_DIR}/kernel-ccsuffix')}"
-KERNEL_LDSUFFIX = "${@base_read_file('${STAGING_KERNEL_DIR}/kernel-ldsuffix')}"
-KERNEL_ARSUFFIX = "${@base_read_file('${STAGING_KERNEL_DIR}/kernel-arsuffix')}"
-
-# Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture
-# specific options necessary for building the kernel and modules.
-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_AR_KERNEL_ARCH ?= ""
-HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"
-
-KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc${KERNEL_CCSUFFIX} ${HOST_CC_KERNEL_ARCH}"
-KERNEL_LD = "${HOST_PREFIX}ld${KERNEL_LDSUFFIX} ${HOST_LD_KERNEL_ARCH}"
-KERNEL_AR = "${HOST_PREFIX}ar${KERNEL_ARSUFFIX} ${HOST_AR_KERNEL_ARCH}"
 
 # kernel modules are generally machine specific
 PACKAGE_ARCH = "${MACHINE_ARCH}"