Cross-compiling is taking a computer program and compiling it for a machine that isn’t the one hosting the compilation. Although historically compilers would only compile for the host machine, this is considered an anachronism: all serious native compilers are now cross-compilers. After all, you don’t want to be building your iPhone app on literal iPhone hardware. Many different compilers have different mechanisms for classifying and identifying targets. A target is a platform that the compiler can produce executable code for. However, due to the runaway popularity of LLVM, virtually all compilers now use target triples. You may have already encountered one, such as the venerable x86_64-unknown-linux, or the evil x86_64-pc-windows. This system is convoluted and almost self-consistent. But what is a target triple, and where did they come from? So if you go poking around the Target Triplet page on OSDev, you will learn both true and false things about target triples, because this page is about GCC, not native compilers in general. Generally, there is no “ground truth” for what a target triple is. There isn’t some standards body that assigns these names. But as we’ll see, LLVM is the trendsetter. If you run the following command you can learn the target triple for your machine: $ gcc -dumpmachine x86_64-linux-gnu Now if you’re at all familiar with any system that makes pervasive use of target triples, you will know that this is not a target triple, because this target’s name is x86_64-unknown-linux-gnu, which is what both clang and rustc call- $ clang -dumpmachine x86_64-pc-linux-gnu $ rustc -vV | grep host host: x86_64-unknown-linux-gnu Oh no. Well, GCC is missing the the pc or unknown component, and that’s specifically a GCC thing; it allows omitting parts of the triple in such a way that is unambiguous. And they are a GCC invention, so perhaps it’s best to start by assessing GCC’s beliefs. According to GCC, a target triple is a string of the form <machine>-<vendor>-...
First seen: 2025-04-15 19:14
Last seen: 2025-04-16 00:15