when working with toolchain metadata, i run into the terminology “triple” a lot (example: Triple.swift), and as far as i understand, it’s just an encoding for information about a platform.
what exactly does triple mean? why do we even have this word (it doesn’t seem to refer to the number of hyphen-separated components, of which it has four), and how is it different from platform? when naming a type that models this thing, does it even make sense to call it a PlatformTriple?
This is one of those horrible legacy situations where it originally did have three components, so it was called a “triple”, but then it got extended so there are sometimes now four or even five components and the name doesn’t make as much sense anymore.
“Platform” is a very vague word—does it encompass only the OS, or the OS and architecture?—whereas “triple” is very precise. It’s a set of 3-5 pieces of data that describe a build’s target. These include the CPU architecture, the OS vendor, the OS, the “environment” (like macabi for Mac Catalyst, simulator for iOS simulators, or the libc for certain Linux configurations), and the object file format. The environment and object file format are often empty or defaulted, so they can be left off in many cases. This set of fields are the main information LLVM uses to figure out how to emit machine code.
armv7k_be-arm-linux-gnueabihf6.3.3-macho would be a 10-part triple specifying:
Endianness: Big Endian
Vendor: ARM Ltd
libc: GNU (glibc)
ABI: EABI (embedded ABI)
Variant: Hardware Floating Point
OS Version: 6.3.3
File Format: Mach-O