在 BitBake 配方中可靠地确定机器架构
Determine machine architecture reliably in a BitBake recipe
我正在为需要了解底层机器微体系结构的程序包编写配方。换句话说,对于 64 位 Arm 系统,我想要一个字符串,例如 aarch64
或 arm64
,对于 64 位 Intel 系统,我想要一个字符串 x86_64
。
到目前为止,我已经确定:
MACHINE
- 这似乎是 meta-*
层作者决定命名他们的机器并且可能包含架构的任何内容,它可能不包含。例如,beaglebone
是没有用的。
MACHINE_ARCH
- 这似乎接近我要找的东西。但是,以this BSP层为例,快速搜索一下,似乎并没有在任何地方设置这个变量。只读了几个包。
TUNE_PKGARCH
- 可能是迄今为止最好的选择。但是,这个变量的格式是什么?使用什么架构命名约定?此外,上述 BSP 层似乎也没有在任何地方设置它。
我原以为以明确定义的格式了解机器架构很重要,但似乎并没有那么简单。有什么建议吗?
我习惯用 uname -m
来做这个(Windows 粉丝可以使用 SET processor
的输出),所以对我来说,在 Yocto 中它最终是一个折腾:
- 根据 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
更好一些,因为您还可以获得子架构信息。从我此刻可以访问的机器:
Intel-based Nuc build system: x86_64
ARM embedded system: armv7l
Raspberry Pi 4B: aarch64
我发现 GNU automake
(本机)和 libtool
(可用于目标)包计算一个名为 UNAME_MACHINE_ARCH 的有用变量。如果您已经在使用 libtool
或愿意接受它只是为了为您完成此操作:-@),您可以通过这种方式解决。在构建的树中查找名为 config.guess
.
的文件
通过使用 Yocto BUILD_ARCH:
,您可能比 libtool
更通用
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.
因此,请使用这些并根据您的项目情况做出自己的选择。
我正在为需要了解底层机器微体系结构的程序包编写配方。换句话说,对于 64 位 Arm 系统,我想要一个字符串,例如 aarch64
或 arm64
,对于 64 位 Intel 系统,我想要一个字符串 x86_64
。
到目前为止,我已经确定:
MACHINE
- 这似乎是meta-*
层作者决定命名他们的机器并且可能包含架构的任何内容,它可能不包含。例如,beaglebone
是没有用的。MACHINE_ARCH
- 这似乎接近我要找的东西。但是,以this BSP层为例,快速搜索一下,似乎并没有在任何地方设置这个变量。只读了几个包。TUNE_PKGARCH
- 可能是迄今为止最好的选择。但是,这个变量的格式是什么?使用什么架构命名约定?此外,上述 BSP 层似乎也没有在任何地方设置它。
我原以为以明确定义的格式了解机器架构很重要,但似乎并没有那么简单。有什么建议吗?
我习惯用 uname -m
来做这个(Windows 粉丝可以使用 SET processor
的输出),所以对我来说,在 Yocto 中它最终是一个折腾:
- 根据 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
更好一些,因为您还可以获得子架构信息。从我此刻可以访问的机器:
Intel-based Nuc build system: x86_64
ARM embedded system: armv7l
Raspberry Pi 4B: aarch64
我发现 GNU
的文件automake
(本机)和libtool
(可用于目标)包计算一个名为 UNAME_MACHINE_ARCH 的有用变量。如果您已经在使用libtool
或愿意接受它只是为了为您完成此操作:-@),您可以通过这种方式解决。在构建的树中查找名为config.guess
.通过使用 Yocto BUILD_ARCH:
,您可能比libtool
更通用
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.
因此,请使用这些并根据您的项目情况做出自己的选择。