toolchain technical note: rewrite the descrption for triplet

- Don't say "most building system", refine the dicussion for autoconf.
  Other building systems may use a variant of triplet, or use a
  completely different system designation.
- Explain why a triplet may contain 4 fields in detail. "Histroical
  reason" is not really correct because 3-field triplet is still used
  today for BSD, Fuchsia, IOS, Mac OS X (darwin), Solaris, etc.
- "machine" triplet to "system" triplet (strictly speaking, only the
  first field in the triplet is for the machine).

Why we need to say "vendor can be omitted" explicitly: we mention "gcc
-dumpmachine".  On some distros (like Ubuntu) the output has no vendor
field.  If you think this is too nasty, please remove both.
This commit is contained in:
Xi Ruoyao 2022-09-30 10:39:03 +08:00
parent cc0e77d267
commit e18ba697eb
No known key found for this signature in database
GPG Key ID: ACAAD20E19E710E3

View File

@ -145,15 +145,28 @@
<title>Implementation of Cross-Compilation for LFS</title>
<note>
<para>Almost all the build systems use names of the form
cpu-vendor-kernel-os, referred to as the machine triplet. (Sometimes,
the vendor field is omitted.) An astute
reader may wonder why a <quote>triplet</quote> refers to a four component
name. The reason is historical: initially, three component names were enough
to designate a machine unambiguously, but as new machines and systems
proliferated, that proved insufficient. The word <quote>triplet</quote>
remained. A simple way to determine your machine triplet is to run
the <command>config.guess</command>
<para>All packages involved with cross compilation in the book use an
autoconf-based building system. The autoconf-based building system
accepts system types in the form cpu-vendor-kernel-os,
referred to as the system triplet. Since the vendor field is mostly
irrelevant, autoconf allows to omit it. An astute reader may wonder
why a <quote>triplet</quote> refers to a four component name. The
reason is the kernel field and the os field originiated from one
<quote>system</quote> field. Such a three-field form is still valid
today for some systems, for example
<literal>x86_64-unknown-freebsd</literal>. But for other systems,
two systems can share the same kernel but still be too different to
use a same triplet for them. For example, an Android running on a
mobile phone is completely different from Ubuntu running on an ARM64
server. Without an emulation layer, you cannot run an executable for
the server on the mobile phone or vice versa. So the
<quote>system</quote> field is separated into kernel and os fields to
designate these systems unambiguously. For our example, the Android
system is designated <literal>aarch64-unknown-linux-android</literal>,
and the Ubuntu system is designated
<literal>aarch64-unknown-linux-gnu</literal>. The word
<quote>triplet</quote> remained. A simple way to determine your
system triplet is to run the <command>config.guess</command>
script that comes with the source for many packages. Unpack the binutils
sources and run the script: <userinput>./config.guess</userinput> and note
the output. For example, for a 32-bit Intel processor the