152

Currently I am interested in ARM in general and specifically iPhone/Android targets. But I just want to know more about clang, since it feels to play important role in the years to come.

I tried

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) 

I know clang has -triplet parameter, but how can I list all possible values for it?

I found that clang is very different to gcc in respect to cross compiling, in GCC world you should have separate binary for everything, like PLATFORM_make or PLATFORM_ld (i*86-pc-cygwin i*86-*-linux-gnu etc. http://git.savannah.gnu.org/cgit/libtool.git/tree/doc/PLATFORMS)

In clang world, it's only one binary (as I read on some forums). But how do I get the list of supported targets? And if my target it not supported on my distro (Linux/Windows/macOS/whatever) how can I get the one that supports more platform?

If I SVN latest clang like this:

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

will I get most of platforms?

It looks like Clang was not built with cross compiling in mind right away, but since it's LLVM-based it should be very cross-friendly in theory?

4
  • 11
    not a complete answer but llc --version will give you the targets Commented Feb 23, 2013 at 4:13
  • 1
    I think you'll have to look at the source to see the triples. And as I understand it a default build of clang will include basic support for cross compiling. Basic support only turns code into object files (as long as the integrated assembler supports the triple, otherwise you'll have to take .s files). You'll have to supply headers, libraries, a linker (until lld works, anyway), etc. Commented Feb 23, 2013 at 4:15
  • 1
    Although the default installation only has clang and clang++ executables, like other platforms you can create copies or hardlinks of them with the triples and quads encoded in the names. clang++ and clang are actually just copies of each other it checks the name of the executable to see how to process input. Commented Jun 6, 2013 at 13:31
  • 1
    Related - Which targets does Clang support?. Commented Apr 9, 2018 at 7:44

14 Answers 14

84

Starting with Clang 11 (trunk), the list of supported target architectures could be handily printed using the newly added -print-targets flag:

$ clang -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 

References: LLVM PR, LLVM commit, Clang 11 documentation.

Sign up to request clarification or add additional context in comments.

4 Comments

Is arm 32 bit?
Yes, arm is 32 bit.
Is it possible in 2024 to know what are the valid inputs to the -target option? E.g. aarch64-linux-android10000, etc.
this just prints out the target architecture, not the triplet
81
+250

So far as I can tell, there is no command-line option to list which architectures a given clang binary supports, and even running strings on it doesn't really help. Clang is essentially just a C to LLVM translator, and it's LLVM itself that deals with the nitty-gritty of generating actual machine code, so it's not entirely surprising that Clang isn't paying much attention to the underlying architecture.

As others have already noted, you can ask llc which architectures it supports. This isn't all that helpful not just because these LLVM components might not be installed, but because of the vagaries of search paths and packaging systems, your llc and clang binaries may not correspond to the same version of 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 will give a list of all architectures it supports. By default, it is compiled to support all architectures. What you may think of as a single architecture such as ARM may have several LLVM architectures such as regular ARM, Thumb and AArch64. This is mainly for implementation convenience because the different execution modes have very different instruction encodings and semantics.
  • For each of the architectures listed, llc -march=ARCH -mattr=help will list "available CPUs" and "available features". The CPUs are generally just a convenient way of setting a default collection of features.

But now for the bad news. There is no convenient table of triples in Clang or LLVM that can be dumped, because the architecture-specific backends have the option of parsing the triple string into an llvm::Triple object (defined in include/llvm/ADT/Triple.h). In other words, to dump all available triples requires solving the Halting Problem. See, for example, llvm::ARM_MC::ParseARMTriple(...) which special-cases parsing the string "generic".

Ultimately, though, the "triple" is mostly a backwards-compatibility feature to make Clang a drop-in replacement for GCC, so you generally don't need to pay much attention to it unless you are porting Clang or LLVM to a new platform or architecture. Instead, you will probably find the output of llc -march=arm -mattr=help and boggling at the huge array of different ARM features to be more useful in your investigations.

Good luck with your research!

Comments

43

I am using Clang 3.3, I think the best way to get the answer is reading the source code.
in llvm/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 }; 

and in clang/lib/Driver/ToolChains.cpp , there is sth about 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); } 

4 Comments

what about second and third parts of the Triple?
And actual parser of Arch name into ArchType is in code.metager.de/source/xref/llvm/llvm/lib/Support/… - llvm/lib/Support/Triple.cpp function static Triple::ArchType parseArch(StringRef ArchName)
The clang binary being available doesn't mean the user compiled it from source.
Some descriptions of clang's targets and triples: llvm.org/devmtg/2014-04/PDFs/LightningTalks/…, proposed in 2014: "Target Triple: <arch><sub>-<vendor>-<sys>-<abi>; --print-supported-archs --print-supported-vendors --print-supported-systems --print-supported-abis --print-multi-libs --print-available-targets" and clang.llvm.org/UniversalDriver.html
29

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 

or alternatively:

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

Then you know how to target it when cross compiling anyway.

Apparently there are "lots" of targets out there, here's a list, feel free to add to it, community wiki style:

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 # same as i686-w64-mingw32 x86_64-pc-windows-gnu # same as x86_64-w64-mingw32 i686-pc-windows-msvc # MSVC x86_64-pc-windows-msvc # MSVC 64-BIT 

Here's what the docs list anyway (apparently it's a quadruple [or quintuple?] instead of a triple these days):

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. 

and you can even fine tune specify a target cpu beyond this, though it uses a sensible default for the target cpu based on the triple.

Sometimes targets "resolve" to the same thing, so to see what a target is actually treated as:

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

5 Comments

When is says mingw32 does it means it won't work with MinGW64? Is there something which is MSVC Compatible?
@Royi stackoverflow.com/q/39871656/32453 may be useful, good luck!
How come win32 is there but not win64?
I think i686-w64-mingw32 is 32 bit but targeting the "mingw w64" toolchain. Which also has a 32-bit version of itself. Go figure...
Microsoft made quite a mess there. Win32 and mingw32 both mean Win32 API that was introduced with 32-bit Windows. 64-bit Windows uses the same Win32 API.
16

According to Jonathan Roelofs in this talk “Which targets does Clang support?”:

$ 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 

Future versions of Clang may provide the following. They are listed as "proposed" though not yet available at least as of v 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 

1 Comment

Looks like it doesn't work on newer Clang versions.
7

Also try

> 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. ... 

5 Comments

clang being available doesn't mean llc is available.
seems llc is commonly installed along with clang, however...and you can install it if not from your package manager and and it should line up, I'd guess...however this list appears to be if you want to target a specific cpu, not necessarily a different "triple" architecture, as the OP wanted...
To list options for other architectures, you can use the -mtriple option as in llc -mtriple=arm -mattr=help.
llc: error: : error: unable to get target for 'unknown', see --version and --triple.
use $ llc --version
7
$ aarch64-linux-android30-clang++ -print-targets Registered Targets: aarch64 - AArch64 (little endian) aarch64_32 - AArch64 (little endian ILP32) aarch64_be - AArch64 (big endian) arm - ARM arm64 - ARM64 (little endian) arm64_32 - ARM64 (little endian ILP32) armeb - ARM (big endian) bpf - BPF (host endian) bpfeb - BPF (big endian) bpfel - BPF (little endian) thumb - Thumb thumbeb - Thumb (big endian) x86 - 32-bit X86: Pentium-Pro and above x86-64 - 64-bit X86: EM64T and AMD64 $ aarch64-linux-android30-clang++ -print-supported-cpus Android (8490178, based on r450784d) clang version 14.0.6 (https://android.googlesource.com/toolchain/llvm-project 4c603efb0cca074e9238af8b4106c30add4418f6) Target: aarch64-unknown-linux-android30 Thread model: posix InstalledDir: /opt/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin Available CPUs for this target: a64fx apple-a10 apple-a11 apple-a12 apple-a13 apple-a14 apple-a7 apple-a8 apple-a9 apple-latest apple-m1 apple-s4 apple-s5 carmel cortex-a34 cortex-a35 cortex-a510 cortex-a53 cortex-a55 cortex-a57 cortex-a65 cortex-a65ae cortex-a710 cortex-a72 cortex-a73 cortex-a75 cortex-a76 cortex-a76ae cortex-a77 cortex-a78 cortex-a78c cortex-r82 cortex-x1 cortex-x2 cyclone exynos-m3 exynos-m4 exynos-m5 falkor generic kryo neoverse-512tvb neoverse-e1 neoverse-n1 neoverse-n2 neoverse-v1 saphira thunderx thunderx2t99 thunderx3t110 thunderxt81 thunderxt83 thunderxt88 tsv110 

1 Comment

the question is about the target triples, not targets
6

clang -march=dont-know empty.c

error: unknown target CPU 'dont-know'

note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64

3 Comments

No longer, at least with Apple clang version 14.0.0 (clang-1400.0.29.102): “clang: error: the clang compiler does not support '-march=dont-know'”
It is working with opensource latest clang-16, don't know about Apple clang.
the question is about listing all -triplets or at least all the architectures, not x86 micro architectures
6

I don't know a way to get all the available triples with standard clang or llc commands. The closest is llc -mtriple=ARCH -mattr=help from
Lekensteyn's comment
but it doesn't work. It just prints a huge list of CPUs and features

However if you have rust then it's easy to do using rustc --print target-list. Currently I'm seeing a list of 181 different triples [Update 2025-11-21: I'm seeing 288 now]. I'm not entirely sure if it's all the possible values or not but it's definitely much more than other methods that actually print out triples in this question that I've tried

$ 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. It's somewhat different from rustc --print target-list, I have no idea why, but at least it still prints out more triplets than solutions with direct clang invocation

$ 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 

Comments

3

It won't list all the triples, but

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

will at least list all the CPUs.

2 Comments

This will list only options, which can be applied to the current (default) target.
llc: error: : error: unable to get target for 'unknown', see --version and --triple.
3

In case you are interested in which targets are supported for building LLVM or Clang from source (the values for -DLLVM_TARGETS_TO_BUILD), look for the list of subdirectories in llvm/lib/Target folder in source distribution. As of 9.0.1 there are:

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

1 Comment

I try to reconfigure the failing build, and this is the only way I found to work.
2

For those that ended up here looking to see if their specific x86 CPU family architecture has a target for llvm/clang optimisation (.e.g: zen3, zen1, skylake, penryn, etc)

You can view the list underneath or run this:

$ 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. 

The list above is current as of 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.

1 Comment

the question is about listing all -triplets or at least all the architectures, not x86 micro architectures
2

For those interested in CPUs to tune for, you can use --print-supported-cpus (added here). If your clang binary can compile for more than one architecture, you have to pass --target as well to select the proper architecture; for instance, to list the ARM CPUs available on the Android cross compiler, you could use --target=aarch64-unknown-linux-gui.

Comments

0

Only the first one (CPU architecture) need to be exact, other parameters are processed in a smart and complex way, you can use "clang++ ... --verbose ..." to see the processed result, for example:

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 

Commonly the parameters except the first one will only have effect when they are right (after the triple proceesing process which may make a wrong one right smartly), for example, "windows" will effect the code:

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

This method is used by other code in Clang/LLVM to affect the compiled result, it only return true when the parameter is "windows" and will return false if it is any other thing such as "foo".

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.