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:
ripgrep-13.0.0-arm-unknown-linux-gnueabihf.tar.gz
ripgrep-13.0.0-i686-pc-windows-msvc.zip
ripgrep-13.0.0-x86_64-apple-darwin.tar.gz
ripgrep-13.0.0-x86_64-pc-windows-gnu.zip
ripgrep-13.0.0-x86_64-pc-windows-msvc.zip
ripgrep-13.0.0-x86_64-unknown-linux-musl.tar.gz
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:
- The ARM architecture (
arm
) - From any vendor (
unknown
) - For a Linux-based OS (
linux
) - Cross-compiled for the ARM Embedded ABI with hardware floating-point linkage (
gnueabihf
)
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:
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
.