[yocto] ARM CPU version question
Andre McCurdy
armccurdy at gmail.com
Mon Mar 19 17:14:58 PDT 2018
On Mon, Mar 19, 2018 at 4:35 PM, Steve Pavao <stevep at korgrd.com> wrote:
>
> I think I may have discovered a specific situation which is causing the
> problem to occur for me. It seems it occurs because I am trying to build a
> kernel module under the recipes-kernel directory in my custom layer. A
> colleague pointed out to me that meta/classes/module.bbclass explicitly
> unsets CFLAGS and a bunch of other macros in this situation.
OK, but note that the kernel (and kernel modules) are quite different
to user space in the way that CFLAGS and -mcpu etc are setup. For code
which runs in user space, these options are set by the OE build
environment, based on the machine config. For code which runs in
kernel space, these options come from the kernel build system, based
on the kernel config.
ie it's quite correct for module.bbclass to unset CFLAGS etc - it
prevents OE's flags for user space contaminating or conflicting with
the flags set by the kernel build system.
> Maybe I need to put in some custom shell syntax in my recipe, to export
> __ARM_ARCH_6__ or to directly define the compiler macro when needed, based
> on the value of the TARGET variable. I wonder if there is a better
> recommended solution than this, though.
__ARM_ARCH_6__ is one of the macros normally set internally by gcc, so
you shouldn't be trying to set it manually.
Instead, you should probably either:
1) Update your code to test for defined(__ARM_ARCH_6__) ||
defined(__ARM_ARCH_6K__), since according to:
https://github.com/torvalds/linux/blob/master/arch/arm/Makefile#L65
the kernel will either pass -march=armv6 or -march=armv6k for ARMv6
targets (depending on whether or not your kernel config enables
CONFIG_CPU_32v6K).
2) Update your code to test the generic ARMv6 macro set by the kernel
build system, ie (__LINUX_ARM_ARCH__ == 6), which should catch all
ARMv6 targets.
> BTW, my kernel module contains conditionally-compiled code for initializing
> the ARM PMU correctly for each CPU case.
>
More information about the yocto
mailing list