What’s an LLVM target triple?

Today I learnt …

When you want to download a software release you often have to choose between files with seemingly incomprehensible names. To pick ripgrep as an example, the v13.0.0 release offers several options:

The apple/windows/linux bit helps, but otherwise the filenames are fairly inscrutable. How are you supposed to choose between them?

Well, the bit between the software’s name and version number and the file extension — arm-unknown-linux-gnueabihf for example — is known as an LLVM target triple. ‘LLVM’ from the software that defined the term, ‘target’ because it defines the target architecture, and ‘triple’ because it originally had exactly three parts (today it can have between two and five parts, which makes parsing it a little painful). The syntax is:

<arch><sub_arch>-<vendor>-<sys>-<env>

You can see all the available values in the llvm::Triple class.

From that we can determine that arm-unknown-linux-gnueabihf means:

Quite the mouthful!

If you want to see the unambiguous target triple for your system, run gcc -dumpmachine. The output on my 2020 M1 MacBook Pro is:

$ gcc -dumpmachine
arm64-apple-darwin21.6.0

Unfortunately, that tells me that there is no pre-built download available directly from the ripgrep v13.0.0 release — they offer x86_64-apple-darwin while I need arm64-apple-darwin.