[yocto] ARM CPU version question

Andre McCurdy armccurdy at gmail.com
Mon Mar 19 14:32:39 PDT 2018


On Mon, Mar 19, 2018 at 9:49 AM, Steve Pavao <stevep at korgrd.com> wrote:
> What’s the recommended way to be able to propogate target-specific compile-time CPU tune information to affect the build of a source file in my own custom layer?
>
> For example, if I’m building for an arm6-based target, I’d like to be able to have the __ARM_ARCH_6__ symbol be available when the Yocto system builds my custom layer.  The BSP for such a target obviously defines this symbol when building its files for such a target.  Is there an easy way to propagate this information to my own custom layer, to affect my own sources?  Maybe my recipe needs to include certain conf files from other layers such as meta or the BSP layer?

This kind of macro is typically defined internally by gcc, depending
on the -mcpu etc options passed on the gcc command line, ie options
which are included in the ${CC} definition setup by OE.

Therefore all you normally need to do is ensure that the Makefiles etc
for the components in your custom layer all correctly respect OE's
definition of ${CC}.

A typical bug in handcrafted Makefiles is to force CC to (e.g. CC =
"$(CROSS_COMPILE)gcc") and lose the original value passed via the
environment.

> Currently, I notice that architecture-level symbols are available to my custom layer at compile time, such as __aarch64_ and __arm__, but not CPU tune information, such as __ARM_ARCH_6__.

The exact set of macros defined by gcc will vary depending on exactly
which ARMv6 CPU you are targeting (and to some extent, which version
of gcc you are using). If you have code which needs to be enabled for
any ARMv6 target then you may have to test multiple macros. For
example see the way in which openssl defines __ARM_ARCH__

  https://github.com/openssl/openssl/blob/master/crypto/arm_arch.h

> - Steve Pavao
> Korg R&D
> --
> _______________________________________________
> yocto mailing list
> yocto at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto



More information about the yocto mailing list