2

I am writing a recipe for a package which needs to be aware of the underlying machine's microarchitecture. In other words, I would like a string such as aarch64 or arm64 for a 64-bit Arm system, and x86_64 for a 64-bit Intel system.

So far, I have identified:

  • MACHINE - This seems to be whatever the meta-* layer author decides to name their machine and may contain the architecture, it may not. For example, beaglebone is no use.

  • MACHINE_ARCH - This seems to be close to what I'm looking for. However, taking this BSP layer as an example, and doing a quick search, it doesn't seem as though this variable is set anywhere. Only read from in a few packages.

  • TUNE_PKGARCH - May be the best bet so far. But, what format is this variable in? What architecture naming conventions are used? Also, the aforementioned BSP layer, again, doesn't seem to set this anywhere.

I would have thought that knowing the machine architecture in a well-defined format is important, but it doesn't seem to be so simple. Any advice?

1 Answers1

2

I'm accustomed to doing this with uname -m (Windows fans can use the output of SET processor), so for me in Yocto it ends up being a toss-up:

  1. According to the Mega-Manual entry for TARGET_ARCH:
TARGET_ARCH

The target machine's architecture. The OpenEmbedded build system supports many
architectures. Here is an example list of architectures supported. This list is by
no means complete as the architecture is configurable:

     arm
     i586
     x86_64
     powerpc
     powerpc64
     mips
     mipsel

uname -m is a bit better since you get subarchitectural information as well. From the machines I have access to at this moment:

Intel-based Nuc build system:  x86_64
ARM embedded system:           armv7l
Raspberry Pi 4B:               aarch64
  1. I have found that the GNU automake (native) and libtool (available for target) packages compute a useful variable named UNAME_MACHINE_ARCH. If you are using libtool already or are willing to take it on just for the purpose of having this done for you :-@), you can solve this way. Look in the built tree for files named config.guess.

  2. You may be able to get by more generically than libtool by using Yocto BUILD_ARCH:

BUILD_ARCH

Specifies the architecture of the build host (e.g. i686). The OpenEmbedded build
system sets the value of BUILD_ARCH from the machine name reported by the uname
command.

So play with these and make your own choice depending on your project's circumstances.

Modus Tollens
  • 5,083
  • 3
  • 38
  • 46
Frank Hoeflich
  • 538
  • 2
  • 9