如何列出支持的目标架构?

目前我对 ARM 感兴趣,一般而言,特别是针对 iPhone/Android 的目标。但我只是想知道更多关于叮当,因为它觉得在未来几年发挥重要作用。

我尽力了

clang -cc1 --help|grep -i list
clang -cc1 --help|grep arch|grep -v search
clang -cc1 --help|grep target


-triple <value>         Specify target triple (e.g. i686-apple-darwin9)

我知道 clang 有 -triplet参数,但是如何列出所有可能的值呢?

我发现 clang 和 GCC 在交叉编译方面有很大的不同,在 GCC 的世界里,任何东西都应该有单独的二进制文件,比如 PLATFORM_make或者 PLATFORM_ld(i*86-pc-cygwin i*86-*-linux-gnu等等。http://git.savannah.gnu.org/cgit/libtool.git/tree/doc/PLATFORMS)

在叮当世界中,它只是一个二进制文件(正如我在一些论坛上读到的)。但是如何获得支持的目标列表呢?如果我的目标不支持我的发行版(Linux/Windows/macOS/whatever) ,我怎样才能得到一个支持更多平台的版本?

If I SVN latest clang like this:

svn co http://llvm.org/svn/llvm-project/cfe/trunk clang

我会得到大部分的平台吗?

看起来 Clang 并不是在交叉编译的基础上构建的,但是由于它是基于 LLVM 的,所以理论上它应该是非常交叉友好的?

134204 次浏览

它不会列出所有的三元组,但是

llvm-as < /dev/null | llc -mcpu=help

will at least list all the CPUs.

我使用的是 Clang 3.3,我认为得到答案的最好方法是阅读源代码。
Lvm/ADT/Triple.h (http://llvm.org/doxygen/Triple_8h_source.html) :

enum ArchType {
UnknownArch,


arm,     // ARM: arm, armv.*, xscale
aarch64, // AArch64: aarch64
hexagon, // Hexagon: hexagon
mips,    // MIPS: mips, mipsallegrex
mipsel,  // MIPSEL: mipsel, mipsallegrexel
mips64,  // MIPS64: mips64
mips64el,// MIPS64EL: mips64el
msp430,  // MSP430: msp430
ppc,     // PPC: powerpc
ppc64,   // PPC64: powerpc64, ppu
r600,    // R600: AMD GPUs HD2XXX - HD6XXX
sparc,   // Sparc: sparc
sparcv9, // Sparcv9: Sparcv9
systemz, // SystemZ: s390x
tce,     // TCE (http://tce.cs.tut.fi/): tce
thumb,   // Thumb: thumb, thumbv.*
x86,     // X86: i[3-9]86
x86_64,  // X86-64: amd64, x86_64
xcore,   // XCore: xcore
mblaze,  // MBlaze: mblaze
nvptx,   // NVPTX: 32-bit
nvptx64, // NVPTX: 64-bit
le32,    // le32: generic little-endian 32-bit CPU (PNaCl / Emscripten)
amdil,   // amdil: amd IL
spir,    // SPIR: standard portable IR for OpenCL 32-bit version
spir64   // SPIR: standard portable IR for OpenCL 64-bit version
};

在 clang/lib/Driver/ToolChains.cpp 中,有关 arm 的内容。

static const char *GetArmArchForMArch(StringRef Value) {
return llvm::StringSwitch<const char*>(Value)
.Case("armv6k", "armv6")
.Case("armv6m", "armv6m")
.Case("armv5tej", "armv5")
.Case("xscale", "xscale")
.Case("armv4t", "armv4t")
.Case("armv7", "armv7")
.Cases("armv7a", "armv7-a", "armv7")
.Cases("armv7r", "armv7-r", "armv7")
.Cases("armv7em", "armv7e-m", "armv7em")
.Cases("armv7f", "armv7-f", "armv7f")
.Cases("armv7k", "armv7-k", "armv7k")
.Cases("armv7m", "armv7-m", "armv7m")
.Cases("armv7s", "armv7-s", "armv7s")
.Default(0);
}


static const char *GetArmArchForMCpu(StringRef Value) {
return llvm::StringSwitch<const char *>(Value)
.Cases("arm9e", "arm946e-s", "arm966e-s", "arm968e-s", "arm926ej-s","armv5")
.Cases("arm10e", "arm10tdmi", "armv5")
.Cases("arm1020t", "arm1020e", "arm1022e", "arm1026ej-s", "armv5")
.Case("xscale", "xscale")
.Cases("arm1136j-s", "arm1136jf-s", "arm1176jz-s", "arm1176jzf-s", "armv6")
.Case("cortex-m0", "armv6m")
.Cases("cortex-a8", "cortex-r4", "cortex-a9", "cortex-a15", "armv7")
.Case("cortex-a9-mp", "armv7f")
.Case("cortex-m3", "armv7m")
.Case("cortex-m4", "armv7em")
.Case("swift", "armv7s")
.Default(0);
}

也试试

> llc -mattr=help


Available CPUs for this target:


amdfam10      - Select the amdfam10 processor.
athlon        - Select the athlon processor.
athlon-4      - Select the athlon-4 processor.
athlon-fx     - Select the athlon-fx processor.
athlon-mp     - Select the athlon-mp processor.
athlon-tbird  - Select the athlon-tbird processor.
athlon-xp     - Select the athlon-xp processor.
athlon64      - Select the athlon64 processor.
athlon64-sse3 - Select the athlon64-sse3 processor.
atom          - Select the atom processor.
...
Available features for this target:


16bit-mode           - 16-bit mode (i8086).
32bit-mode           - 32-bit mode (80386).
3dnow                - Enable 3DNow! instructions.
3dnowa               - Enable 3DNow! Athlon instructions.
64bit                - Support 64-bit instructions.
64bit-mode           - 64-bit mode (x86_64).
adx                  - Support ADX instructions.
...

据我所知,没有命令行选项可以列出给定 clang二进制文件支持的体系结构,甚至在它上面运行 strings也没有多大帮助。Clang 本质上只是一个 C to LLVM 转换器,LLVM 本身处理生成实际机器代码的细节,所以 Clang 没有太多关注底层架构也就不足为奇了。

正如其他人已经指出的,您可以询问 llc支持哪些架构。这不仅仅是因为这些 LLVM 组件可能没有被安装,而且因为搜索路径和打包系统的变化无常,您的 llcclang二进制文件可能不对应于相同版本的 LLVM。

However, for the sake of argument, let's say that you compiled both LLVM and Clang yourself or that you're otherwise happy to accept your LLVM binaries as good enough:

  • llc --version将提供它支持的所有架构的列表。默认情况下,它被编译为支持所有体系结构。您可能认为像 ARM 这样的单一体系结构可能有几种 LLVM 体系结构,比如常规的 ARM、拇指和 AArch64。这主要是为了方便实现,因为不同的执行模式有非常不同的指令编码和语义。
  • 对于所列出的每种架构,llc -march=ARCH -mattr=help将列出“可用 CPU”和“可用特性”。CPU 通常只是设置默认特性集合的一种方便的方式。

坏消息是。Clang 或 LLVM 中没有可以转储的方便的三元组表,因为特定于体系结构的后端可以选择将三元组字符串解析为 llvm::Triple对象(在 include/llvm/ADT/Triple.h中定义)。换句话说,转储所有可用的三元组需要解决停机问题。例如,请参见 llvm::ARM_MC::ParseARMTriple(...),其中特殊情况下解析字符串 "generic"

不过,归根结底,“三元组”主要是一个向后兼容的特性,使 Clang 成为 GCC 的替代品,所以通常不需要太多关注它,除非您正在将 Clang 或 LLVM 移植到一个新的平台或体系结构中。相反,您可能会发现 llc -march=arm -mattr=help的输出和令人难以置信的大量不同的 ARM 功能在您的调查中更有用。

祝你研究顺利!

乔纳森•罗洛夫斯(Jonathan Roelofs)在这次谈话中表示:

$ llc --version
LLVM (http://llvm.org/):
LLVM version 3.6.0
Optimized build with assertions.
Built Apr  2 2015 (01:25:22).
Default target: x86_64-apple-darwin12.6.0
Host CPU: corei7-avx


Registered Targets:
aarch64    - AArch64 (little endian)
aarch64_be - AArch64 (big endian)
amdgcn     - AMD GCN GPUs
arm        - ARM
arm64      - ARM64 (little endian)
armeb      - ARM (big endian)
cpp        - C++ backend
hexagon    - Hexagon
mips       - Mips
mips64     - Mips64 [experimental]
mips64el   - Mips64el [experimental]
mipsel     - Mipsel
msp430     - MSP430 [experimental]
nvptx      - NVIDIA PTX 32-bit
nvptx64    - NVIDIA PTX 64-bit
ppc32      - PowerPC 32
ppc64      - PowerPC 64
ppc64le    - PowerPC 64 LE
r600       - AMD GPUs HD2XXX-HD6XXX
sparc      - Sparc
sparcv9    - Sparc V9
systemz    - SystemZ
thumb      - Thumb
thumbeb    - Thumb (big endian)
x86        - 32-bit X86: Pentium-Pro and above
x86-64     - 64-bit X86: EM64T and AMD64
xcore      - XCore

Clang 的未来版本可能提供以下内容。它们被列为“建议”,但至少在3.9.0版本中还没有:

$ clang -target <target_from_list_above> --print-multi-libs
$ clang -print-supported-archs
$ clang -march x86 -print-supported-systems
$ clang -march x86 -print-available-systems

One hint you can do: if you're trying to find a particular target triple, is to install llvm on that system then do a

$ llc --version | grep Default
Default target: x86_64-apple-darwin16.1.0

或者选择:

$ llvm-config --host-target
x86_64-apple-darwin16.0.0
or
$ clang -v 2>&1 | grep Target
Target: x86_64-apple-darwin16.1.0

那么您就知道在交叉编译时如何定位它了。

显然有“很多”目标在那里,这里有一个列表,随时添加到它,社区维基风格:

arm-none-eabi
armv7a-none-eabi
arm-linux-gnueabihf
arm-none-linux-gnueabi
i386-pc-linux-gnu
x86_64-apple-darwin10
i686-w64-windows-gnu # same as i686-w64-mingw32
x86_64-pc-linux-gnu # from ubuntu 64 bit
x86_64-unknown-windows-cygnus # cygwin 64-bit
x86_64-w64-windows-gnu # same as x86_64-w64-mingw32
i686-pc-windows-gnu # MSVC
x86_64-pc-windows-gnu # MSVC 64-BIT

下面是 医生列表(显然现在是四倍(或五倍?)而不是三倍) :

The triple has the general format <arch><sub>-<vendor>-<sys>-<abi>, where:
arch = x86, arm, thumb, mips, etc.
sub = for ex. on ARM: v5, v6m, v7a, v7m, etc.
vendor = pc, apple, nvidia, ibm, etc.
sys = none, linux, win32, darwin, cuda, etc.
abi = eabi, gnu, android, macho, elf, etc.

你甚至可以在这之外指定一个目标 CPU,尽管它基于三元组为目标 CPU 使用了一个合理的默认值。

有时候,目标“决心”做同样的事情,因此,要看到一个目标实际上被当作什么:

 $ clang -target x86_64-w64-mingw32 -v 2>&1 | grep Target
Target: x86_64-w64-windows-gnu

如果您对从源代码构建 LLVM 或 Clang 所支持的目标(-DLLVM_TARGETS_TO_BUILD的值)感兴趣,请查找源代码发行版中 llvm/lib/Target文件夹中的子目录列表。到9.0.1为止,有:

AArch64
AMDGPU
ARC
ARM
AVR
BPF
Hexagon
Lanai
MSP430
Mips
NVPTX
PowerPC
RISCV
Sparc
SystemZ
WebAssembly
X86

从 Clang 11(主干)开始,可以使用新添加的 -print-targets标志方便地打印支持的目标架构列表:

$ clang-11 -print-targets
Registered Targets:
aarch64    - AArch64 (little endian)
aarch64_32 - AArch64 (little endian ILP32)
aarch64_be - AArch64 (big endian)
amdgcn     - AMD GCN GPUs
arm        - ARM
arm64      - ARM64 (little endian)
arm64_32   - ARM64 (little endian ILP32)
armeb      - ARM (big endian)
avr        - Atmel AVR Microcontroller
bpf        - BPF (host endian)
bpfeb      - BPF (big endian)
bpfel      - BPF (little endian)
hexagon    - Hexagon
lanai      - Lanai
mips       - MIPS (32-bit big endian)
mips64     - MIPS (64-bit big endian)
mips64el   - MIPS (64-bit little endian)
mipsel     - MIPS (32-bit little endian)
msp430     - MSP430 [experimental]
nvptx      - NVIDIA PTX 32-bit
nvptx64    - NVIDIA PTX 64-bit
ppc32      - PowerPC 32
ppc64      - PowerPC 64
ppc64le    - PowerPC 64 LE
r600       - AMD GPUs HD2XXX-HD6XXX
riscv32    - 32-bit RISC-V
riscv64    - 64-bit RISC-V
sparc      - Sparc
sparcel    - Sparc LE
sparcv9    - Sparc V9
systemz    - SystemZ
thumb      - Thumb
thumbeb    - Thumb (big endian)
wasm32     - WebAssembly 32-bit
wasm64     - WebAssembly 64-bit
x86        - 32-bit X86: Pentium-Pro and above
x86-64     - 64-bit X86: EM64T and AMD64
xcore      - XCore

参考文献: LLVM PRLLVM 提交Clang 11文档

clang -march=dont-know empty.c

错误: 未知目标 CPU“不知道”

注意: 有效的目标 CPU 值是: nocona,core2,penryn,bonnell,atom,silvermont,slm,goldmont,goldmont-plus,tremont,nehalem,corei7,Westermere,sandybridge,corei7-avx,Ivybridge,core-avx-i,haswell,core-avx2 Broadwell Skylake Skylake-avx512 skx Cascadelake Cooperlake Cannon Lake 冰湖客户端,冰湖服务器 Tiger erlake knl knm k8 Athlon 64 Athlon-fx opteron,k8-sse3,athlon64-sse3,opteron-sse3,amdfam10,Barcelona,btver1,btver2,bdver1,bdver2,bdver3,bdver4,znver1,znver2,x86-64

只有第一个参数(CPU 体系结构)需要精确,其他参数的处理是智能和复杂的,您可以使用“ clang + + ... ... 详细... ...”来查看处理的结果,例如:

Command Line Input      After triple processing
x86_64                  x86_64
x86_64-foo              x86_64-foo
x86_64-windows          x86_64-unknown-windows-msvc19.28.29335
x86_64-windows-bar      x86_64-unknown-windows-msvc19.28.29335
x86_64-foo-windows-bar  x86_64-foo-windows-msvc19.28.29335
x86_64-foo-bar-foobar   x86_64-foo-bar-foobar

通常情况下,除了第一个参数之外,其他参数只有在它们正确的时候才会有效(在三重处理过程之后,这个过程可能会巧妙地使错误的参数正确) ,例如,“ windows”将影响代码:

/// Tests whether the OS is Windows.
bool isOSWindows() const {
return getOS() == Triple::Win32;
}

这个方法被 Clang/LLVM 中的其他代码用来影响已编译的结果,它只在参数为“ windows”时返回 true,如果参数为其他类似“ foo”的东西,则返回 false。

对于那些最终在这里查看其特定 x86 CPU 系列架构是否有一个 llvm/clang 优化目标(。例如: zen3,zen1,skylake,penryn 等)

您可以查看下面的列表或运行以下命令:

$ llc -march=x86 -mattr=help
Available CPUs for this target:


alderlake      - Select the alderlake processor.
amdfam10       - Select the amdfam10 processor.
athlon         - Select the athlon processor.
athlon-4       - Select the athlon-4 processor.
athlon-fx      - Select the athlon-fx processor.
athlon-mp      - Select the athlon-mp processor.
athlon-tbird   - Select the athlon-tbird processor.
athlon-xp      - Select the athlon-xp processor.
athlon64       - Select the athlon64 processor.
athlon64-sse3  - Select the athlon64-sse3 processor.
atom           - Select the atom processor.
barcelona      - Select the barcelona processor.
bdver1         - Select the bdver1 processor.
bdver2         - Select the bdver2 processor.
bdver3         - Select the bdver3 processor.
bdver4         - Select the bdver4 processor.
bonnell        - Select the bonnell processor.
broadwell      - Select the broadwell processor.
btver1         - Select the btver1 processor.
btver2         - Select the btver2 processor.
c3             - Select the c3 processor.
c3-2           - Select the c3-2 processor.
cannonlake     - Select the cannonlake processor.
cascadelake    - Select the cascadelake processor.
cooperlake     - Select the cooperlake processor.
core-avx-i     - Select the core-avx-i processor.
core-avx2      - Select the core-avx2 processor.
core2          - Select the core2 processor.
corei7         - Select the corei7 processor.
corei7-avx     - Select the corei7-avx processor.
generic        - Select the generic processor.
geode          - Select the geode processor.
goldmont       - Select the goldmont processor.
goldmont-plus  - Select the goldmont-plus processor.
haswell        - Select the haswell processor.
i386           - Select the i386 processor.
i486           - Select the i486 processor.
i586           - Select the i586 processor.
i686           - Select the i686 processor.
icelake-client - Select the icelake-client processor.
icelake-server - Select the icelake-server processor.
ivybridge      - Select the ivybridge processor.
k6             - Select the k6 processor.
k6-2           - Select the k6-2 processor.
k6-3           - Select the k6-3 processor.
k8             - Select the k8 processor.
k8-sse3        - Select the k8-sse3 processor.
knl            - Select the knl processor.
knm            - Select the knm processor.
lakemont       - Select the lakemont processor.
nehalem        - Select the nehalem processor.
nocona         - Select the nocona processor.
opteron        - Select the opteron processor.
opteron-sse3   - Select the opteron-sse3 processor.
penryn         - Select the penryn processor.
pentium        - Select the pentium processor.
pentium-m      - Select the pentium-m processor.
pentium-mmx    - Select the pentium-mmx processor.
pentium2       - Select the pentium2 processor.
pentium3       - Select the pentium3 processor.
pentium3m      - Select the pentium3m processor.
pentium4       - Select the pentium4 processor.
pentium4m      - Select the pentium4m processor.
pentiumpro     - Select the pentiumpro processor.
prescott       - Select the prescott processor.
rocketlake     - Select the rocketlake processor.
sandybridge    - Select the sandybridge processor.
sapphirerapids - Select the sapphirerapids processor.
silvermont     - Select the silvermont processor.
skx            - Select the skx processor.
skylake        - Select the skylake processor.
skylake-avx512 - Select the skylake-avx512 processor.
slm            - Select the slm processor.
tigerlake      - Select the tigerlake processor.
tremont        - Select the tremont processor.
westmere       - Select the westmere processor.
winchip-c6     - Select the winchip-c6 processor.
winchip2       - Select the winchip2 processor.
x86-64         - Select the x86-64 processor.
x86-64-v2      - Select the x86-64-v2 processor.
x86-64-v3      - Select the x86-64-v3 processor.
x86-64-v4      - Select the x86-64-v4 processor.
yonah          - Select the yonah processor.
znver1         - Select the znver1 processor.
znver2         - Select the znver2 processor.
znver3         - Select the znver3 processor.

上面的列表是 llvm-13的当前列表

To run the above you need llvm installed at least and to get the same results as above you need llvm-13 at least.

我不知道如何使用标准的 clangllc命令获得所有可用的三元组。最接近的是来自
Lekensteyn 的注释 但是它不起作用,它只是打印一个巨大的 CPU 列表和特性

然而,如果你有锈然后很容易做使用 rustc --print target-list。目前我看到的是181个不同的三胞胎

$ rustc --print target-list | column
aarch64-apple-darwin                    aarch64_be-unknown-linux-gnu            armv7-unknown-linux-uclibceabi          i686-pc-windows-msvc                    mipsel-unknown-linux-uclibc             riscv32gc-unknown-linux-gnu             thumbv7em-none-eabi                     x86_64-pc-windows-msvc
aarch64-apple-ios                       aarch64_be-unknown-linux-gnu_ilp32      armv7-unknown-linux-uclibceabihf        i686-unknown-freebsd                    mipsel-unknown-none                     riscv32gc-unknown-linux-musl            thumbv7em-none-eabihf                   x86_64-sun-solaris
aarch64-apple-ios-macabi                arm-linux-androideabi                   armv7-unknown-netbsd-eabihf             i686-unknown-haiku                      mipsisa32r6-unknown-linux-gnu           riscv32i-unknown-none-elf               thumbv7m-none-eabi                      x86_64-unknown-dragonfly
aarch64-apple-ios-sim                   arm-unknown-linux-gnueabi               armv7-wrs-vxworks-eabihf                i686-unknown-linux-gnu                  mipsisa32r6el-unknown-linux-gnu         riscv32im-unknown-none-elf              thumbv7neon-linux-androideabi           x86_64-unknown-freebsd
aarch64-apple-tvos                      arm-unknown-linux-gnueabihf             armv7a-kmc-solid_asp3-eabi              i686-unknown-linux-musl                 mipsisa64r6-unknown-linux-gnuabi64      riscv32imac-unknown-none-elf            thumbv7neon-unknown-linux-gnueabihf     x86_64-unknown-haiku
aarch64-fuchsia                         arm-unknown-linux-musleabi              armv7a-kmc-solid_asp3-eabihf            i686-unknown-netbsd                     mipsisa64r6el-unknown-linux-gnuabi64    riscv32imc-esp-espidf                   thumbv7neon-unknown-linux-musleabihf    x86_64-unknown-hermit
aarch64-kmc-solid_asp3                  arm-unknown-linux-musleabihf            armv7a-none-eabi                        i686-unknown-openbsd                    msp430-none-elf                         riscv32imc-unknown-none-elf             thumbv8m.base-none-eabi                 x86_64-unknown-illumos
aarch64-linux-android                   armebv7r-none-eabi                      armv7a-none-eabihf                      i686-unknown-uefi                       nvptx64-nvidia-cuda                     riscv64gc-unknown-freebsd               thumbv8m.main-none-eabi                 x86_64-unknown-l4re-uclibc
aarch64-pc-windows-gnullvm              armebv7r-none-eabihf                    armv7r-none-eabi                        i686-uwp-windows-gnu                    powerpc-unknown-freebsd                 riscv64gc-unknown-linux-gnu             thumbv8m.main-none-eabihf               x86_64-unknown-linux-gnu
aarch64-pc-windows-msvc                 armv4t-unknown-linux-gnueabi            armv7r-none-eabihf                      i686-uwp-windows-msvc                   powerpc-unknown-linux-gnu               riscv64gc-unknown-linux-musl            wasm32-unknown-emscripten               x86_64-unknown-linux-gnux32
aarch64-unknown-freebsd                 armv5te-unknown-linux-gnueabi           armv7s-apple-ios                        i686-wrs-vxworks                        powerpc-unknown-linux-gnuspe            riscv64gc-unknown-none-elf              wasm32-unknown-unknown                  x86_64-unknown-linux-musl
aarch64-unknown-hermit                  armv5te-unknown-linux-musleabi          asmjs-unknown-emscripten                m68k-unknown-linux-gnu                  powerpc-unknown-linux-musl              riscv64imac-unknown-none-elf            wasm32-wasi                             x86_64-unknown-netbsd
aarch64-unknown-linux-gnu               armv5te-unknown-linux-uclibceabi        avr-unknown-gnu-atmega328               mips-unknown-linux-gnu                  powerpc-unknown-netbsd                  s390x-unknown-linux-gnu                 wasm64-unknown-unknown                  x86_64-unknown-none
aarch64-unknown-linux-gnu_ilp32         armv6-unknown-freebsd                   bpfeb-unknown-none                      mips-unknown-linux-musl                 powerpc-unknown-openbsd                 s390x-unknown-linux-musl                x86_64-apple-darwin                     x86_64-unknown-none-linuxkernel
aarch64-unknown-linux-musl              armv6-unknown-netbsd-eabihf             bpfel-unknown-none                      mips-unknown-linux-uclibc               powerpc-wrs-vxworks                     sparc-unknown-linux-gnu                 x86_64-apple-ios                        x86_64-unknown-openbsd
aarch64-unknown-netbsd                  armv6k-nintendo-3ds                     hexagon-unknown-linux-musl              mips64-openwrt-linux-musl               powerpc-wrs-vxworks-spe                 sparc64-unknown-linux-gnu               x86_64-apple-ios-macabi                 x86_64-unknown-redox
aarch64-unknown-none                    armv7-apple-ios                         i386-apple-ios                          mips64-unknown-linux-gnuabi64           powerpc64-unknown-freebsd               sparc64-unknown-netbsd                  x86_64-apple-tvos                       x86_64-unknown-uefi
aarch64-unknown-none-softfloat          armv7-linux-androideabi                 i586-pc-windows-msvc                    mips64-unknown-linux-muslabi64          powerpc64-unknown-linux-gnu             sparc64-unknown-openbsd                 x86_64-fortanix-unknown-sgx             x86_64-uwp-windows-gnu
aarch64-unknown-openbsd                 armv7-unknown-freebsd                   i586-unknown-linux-gnu                  mips64el-unknown-linux-gnuabi64         powerpc64-unknown-linux-musl            sparcv9-sun-solaris                     x86_64-fuchsia                          x86_64-uwp-windows-msvc
aarch64-unknown-redox                   armv7-unknown-linux-gnueabi             i586-unknown-linux-musl                 mips64el-unknown-linux-muslabi64        powerpc64-wrs-vxworks                   thumbv4t-none-eabi                      x86_64-linux-android                    x86_64-wrs-vxworks
aarch64-unknown-uefi                    armv7-unknown-linux-gnueabihf           i686-apple-darwin                       mipsel-sony-psp                         powerpc64le-unknown-freebsd             thumbv6m-none-eabi                      x86_64-pc-solaris
aarch64-uwp-windows-msvc                armv7-unknown-linux-musleabi            i686-linux-android                      mipsel-unknown-linux-gnu                powerpc64le-unknown-linux-gnu           thumbv7a-pc-windows-msvc                x86_64-pc-windows-gnu
aarch64-wrs-vxworks                     armv7-unknown-linux-musleabihf          i686-pc-windows-gnu                     mipsel-unknown-linux-musl               powerpc64le-unknown-linux-musl          thumbv7a-uwp-windows-msvc               x86_64-pc-windows-gnullvm

You can also use rustup target list to print all the triples that rustup supports

$ rustup target list | column
aarch64-apple-darwin                    arm-unknown-linux-gnueabi               armv7-unknown-linux-musleabi            i686-pc-windows-msvc                    mipsel-unknown-linux-musl               s390x-unknown-linux-gnu                 thumbv8m.main-none-eabihf               x86_64-pc-windows-msvc
aarch64-apple-ios                       arm-unknown-linux-gnueabihf             armv7-unknown-linux-musleabihf          i686-unknown-freebsd                    nvptx64-nvidia-cuda                     sparc64-unknown-linux-gnu               wasm32-unknown-emscripten               x86_64-sun-solaris
aarch64-apple-ios-sim                   arm-unknown-linux-musleabi              armv7a-none-eabi                        i686-unknown-linux-gnu                  powerpc-unknown-linux-gnu               sparcv9-sun-solaris                     wasm32-unknown-unknown                  x86_64-unknown-freebsd
aarch64-fuchsia                         arm-unknown-linux-musleabihf            armv7r-none-eabi                        i686-unknown-linux-musl                 powerpc64-unknown-linux-gnu             thumbv6m-none-eabi                      wasm32-wasi                             x86_64-unknown-illumos
aarch64-linux-android                   armebv7r-none-eabi                      armv7r-none-eabihf                      mips-unknown-linux-gnu                  powerpc64le-unknown-linux-gnu           thumbv7em-none-eabi                     x86_64-apple-darwin (installed)         x86_64-unknown-linux-gnu
aarch64-pc-windows-msvc                 armebv7r-none-eabihf                    asmjs-unknown-emscripten                mips-unknown-linux-musl                 riscv32i-unknown-none-elf               thumbv7em-none-eabihf                   x86_64-apple-ios                        x86_64-unknown-linux-gnux32
aarch64-unknown-linux-gnu               armv5te-unknown-linux-gnueabi           i586-pc-windows-msvc                    mips64-unknown-linux-gnuabi64           riscv32imac-unknown-none-elf            thumbv7m-none-eabi                      x86_64-fortanix-unknown-sgx             x86_64-unknown-linux-musl
aarch64-unknown-linux-musl              armv5te-unknown-linux-musleabi          i586-unknown-linux-gnu                  mips64-unknown-linux-muslabi64          riscv32imc-unknown-none-elf             thumbv7neon-linux-androideabi           x86_64-fuchsia                          x86_64-unknown-netbsd
aarch64-unknown-none                    armv7-linux-androideabi                 i586-unknown-linux-musl                 mips64el-unknown-linux-gnuabi64         riscv64gc-unknown-linux-gnu             thumbv7neon-unknown-linux-gnueabihf     x86_64-linux-android                    x86_64-unknown-none
aarch64-unknown-none-softfloat          armv7-unknown-linux-gnueabi             i686-linux-android                      mips64el-unknown-linux-muslabi64        riscv64gc-unknown-none-elf              thumbv8m.base-none-eabi                 x86_64-pc-solaris                       x86_64-unknown-redox
arm-linux-androideabi                   armv7-unknown-linux-gnueabihf           i686-pc-windows-gnu                     mipsel-unknown-linux-gnu                riscv64imac-unknown-none-elf            thumbv8m.main-none-eabi                 x86_64-pc-windows-gnu

对于那些对要优化的 CPU 感兴趣的用户,可以使用 --print-supported-cpus(添加了 给你)。如果您的 clang 二进制文件可以为多个架构进行编译,那么您还必须传递 --target来选择合适的架构; 例如,要列出 Android 交叉编译器上可用的 ARM CPU,您可以使用 --target=aarch64-unknown-linux-gui