2

我正在为一个需要了解底层机器微架构的包编写一个配方。换句话说,我想要一个字符串,例如aarch6464arm64位 Arm 系统和x86_6464 位 Intel 系统的字符串。

到目前为止,我已经确定:

  • MACHINE- 这似乎是meta-*层作者决定命名他们的机器并且可能包含架构的任何内容,它可能不是。例如,beaglebone是没有用的。

  • MACHINE_ARCH- 这似乎接近我正在寻找的东西。但是,以这个BSP 层为例,快速搜索一下,似乎这个变量并没有在任何地方设置。只能从几个包中读取。

  • TUNE_PKGARCH- 可能是迄今为止最好的选择。但是,这个变量是什么格式的?使用了哪些架构命名约定?同样,前面提到的 BSP 层似乎也没有在任何地方设置它。

我会认为以明确定义的格式了解机器架构很重要,但似乎并不那么简单。有什么建议吗?

4

1 回答 1

2

我习惯于这样做uname -m(Windows 粉丝可以使用 的输出SET processor),所以对 Yocto 的我来说,这最终是一个折腾:

  1. 根据TARGET_ARCH的 Mega-Manual 条目:
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好一点,因为您也获得了子架构信息。从我现在可以访问的机器上:

Intel-based Nuc build system:  x86_64
ARM embedded system:           armv7l
Raspberry Pi 4B:               aarch64
  1. 我发现 GNU automake(native) 和libtool(available for target) 包计算了一个名为 UNAME_MACHINE_ARCH 的有用变量。如果您已经使用libtool或愿意接受它只是为了为您完成此操作:-@),您可以通过这种方式解决。在构建的树中查找名为config.guess.

  2. 您可能比libtool使用 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.

因此,请根据您的项目情况使用这些并做出自己的选择。

于 2021-07-16T05:06:40.163 回答