1 From 328f9b88ef896e8e31818c50d9ec2ade5c892ea4 Mon Sep 17 00:00:00 2001
2 From: Bruno Haible <bruno@clisp.org>
3 Date: Fri, 23 Jun 2023 17:37:35 +0200
4 Subject: [PATCH 28/29] INSTALL: Clarify --build, --host, --target, and the
7 * doc/install.texi (Compilers and Options): Add another reference.
8 (System Types): Renamed from System Type. Explain how to canonicalize
9 and how to validate a system type. Don't explain --build, --host,
11 (Building for a different system type): New section.
12 (Troubleshooting the Build Type): New section.
13 (Configuring a Compiler): New section.
14 (configure Invocation): Mention the --host option, not the --build
15 option, since --build is so rarely needed.
17 Upstream-Status: Backport
18 Signed-off-by: Khem Raj <raj.khem@gmail.com>
20 doc/autoconf.texi | 6 +--
21 doc/install.texi | 132 +++++++++++++++++++++++++++++++++++++---------
22 2 files changed, 111 insertions(+), 27 deletions(-)
24 diff --git a/doc/autoconf.texi b/doc/autoconf.texi
25 index 7817fc1b5..043f7fb21 100644
26 --- a/doc/autoconf.texi
27 +++ b/doc/autoconf.texi
28 @@ -604,7 +604,7 @@ Running @command{configure} Scripts
29 * Multiple Architectures:: Compiling for multiple architectures at once
30 * Installation Names:: Installing in different directories
31 * Optional Features:: Selecting optional features
32 -* System Type:: Specifying the system type
33 +* System Types:: Specifying a system type
34 * Sharing Defaults:: Setting site-wide defaults for @command{configure}
35 * Defining Variables:: Specifying the compiler etc.
36 * configure Invocation:: Changing how @command{configure} runs
37 @@ -22383,7 +22383,7 @@ system it's running on. To do so it runs a script called
38 command or symbols predefined by the C preprocessor.
40 Alternately, the user can specify the system type with command line
41 -arguments to @command{configure} (@pxref{System Type}. Doing so is
42 +arguments to @command{configure} (@pxref{System Types}. Doing so is
44 cross-compiling. In the most complex case of cross-compiling, three
45 system types are involved. The options to specify them are:
46 @@ -23303,7 +23303,7 @@ may use comes with Autoconf.
47 * Multiple Architectures:: Compiling for multiple architectures at once
48 * Installation Names:: Installing in different directories
49 * Optional Features:: Selecting optional features
50 -* System Type:: Specifying the system type
51 +* System Types:: Specifying a system type
52 * Sharing Defaults:: Setting site-wide defaults for @command{configure}
53 * Defining Variables:: Specifying the compiler etc.
54 * configure Invocation:: Changing how @command{configure} runs
55 diff --git a/doc/install.texi b/doc/install.texi
56 index 6d9788fa9..a3ef17828 100644
57 --- a/doc/install.texi
58 +++ b/doc/install.texi
59 @@ -157,8 +157,16 @@ Here is an example:
60 ./configure CC=gcc CFLAGS=-g LIBS=-lposix
63 -@xref{Defining Variables}, for more details.
66 +@ref{Defining Variables} and
68 +@ref{Preset Output Variables}
71 +@ref{Preset Output Variables,,, autoconf, Autoconf}
72 +@c (@url{https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.71/html_node/Preset-Output-Variables.html})
76 @node Multiple Architectures
77 @section Compiling For Multiple Architectures
78 @@ -263,18 +271,17 @@ output, which can be overridden with @code{make V=1}; while running
79 @samp{./configure --disable-silent-rules} sets the default to verbose,
80 which can be overridden with @code{make V=0}.
83 -@section Specifying the System Type
85 +@section Specifying a System Type
87 -There may be some features @command{configure} cannot figure out
88 -automatically, but needs to determine by the type of machine the package
89 -will run on. Usually, assuming the package is built to be run on the
90 -@emph{same} architectures, @command{configure} can figure that out, but
91 -if it prints a message saying it cannot guess the machine type, give it
92 -the @option{--build=@var{type}} option. @var{type} can either be a
93 -short name like @samp{mingw64} for the system type, or a canonical name
94 -like @samp{x86_64-pc-linux-gnu}
96 +The following sections go into details regarding situations where you
97 +may have to specify a system type, either through the option
98 +@option{--host=@var{type}}, or through the option
99 +@option{--build=@var{type}}, or -- in the case of compilers -- through
100 +@option{--target=@var{type}}.
102 +A system type @var{type} can either be a short name like @samp{mingw64},
103 +or a canonical name like @samp{x86_64-pc-linux-gnu} which has the form:
106 @var{cpu}-@var{company}-@var{system}
107 @@ -291,16 +298,93 @@ where @var{system} can have one of these forms:
109 See the file @file{config.sub} for the possible values of each field.
110 If @file{config.sub} isn't included in this package, then this package
111 -doesn't need to know the machine type.
112 +doesn't need to know any machine type.
114 +The file @file{config.sub} is a program that validates and canonicalizes
116 +It can do canonicalization, as in
119 +$ sh config.sub x86_64-linux
121 +$ sh config.sub arm64-linux
122 +aarch64-unknown-linux-gnu
126 +It also validates the parts. For example, this interaction tells you
127 +that ``crusoe'' is not a valid cpu architecture name:
129 -If you are @emph{building} compiler tools for cross-compiling, you
130 -should use the option @option{--target=@var{type}} to select the type of
131 -system they will produce code for.
133 +$ sh config.sub crusoe-linux
134 +Invalid configuration `crusoe-linux': machine `crusoe-unknown' not recognized
137 +@node Building for a different system type
138 +@section Creating binaries for a different system type
140 +When you want to create binaries that will run on a different machine
141 +type than the one you are building on, you need to specify both
144 +a @option{--host=@var{type}} option, specifying the machine type on
145 +which the binaries shall run,
147 +compiler variables (@code{CC} for the C compiler, @code{CXX} for the C++
148 +compiler, and so on), pointing to compilers that generate object code
149 +for that machine type.
152 +For example, to create binaries intended to run on a 64-bit ARM
155 +./configure --host=aarch64-linux-gnu \
156 + CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++
159 -If you want to @emph{use} a cross compiler, that generates code for a
160 -platform different from the build platform, you should specify the
161 -@dfn{host} platform (i.e., that on which the generated programs will
162 -eventually be run) with @option{--host=@var{type}}.
163 +If you do this on a machine that can execute such binaries (e.g.@: by
164 +virtue of the @code{qemu-aarch64} program, system libraries for that
165 +architecture under @code{$QEMU_LD_PREFIX}, and a Linux
166 +@code{binfmt_misc} configuration), the build behaves like a native
168 +If not, the build is a cross-build, in the sense that @code{configure}
169 +will make cross-compilation guesses instead of running test programs,
170 +and ``make check'' will not work.
172 +@node Troubleshooting the Build Type
173 +@section Fixing a ``cannot guess build type'' error
175 +In rare cases, it may happen that @code{configure} fails with the error
176 +message ``cannot guess build type''.
177 +This error means that the files @file{config.guess} and
178 +@file{config.sub} don't recognize the type of the system on which you
180 +In this case, first fetch the newest versions of these files, from
181 +@url{https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess}
183 +@url{https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub},
184 +respectively, and use these as drop-in replacement for the files
185 +@file{config.guess} and @file{config.sub} that were shipped with this
188 +If this resolves the problem, feel free to report the solution to the
189 +maintainers of this package.
191 +Otherwise, it means that your system is not yet supported by
192 +@file{config.guess} and @file{config.sub}.
193 +As a workaround, you can use a configure option
194 +@option{--build=@var{type}}, where @var{type} comes closest to your
196 +Also, you're welcome to file a report to
197 +@email{config-patches@@gnu.org}.
199 +@node Configuring a Compiler
200 +@section Configuration options specific to a compiler
202 +If you are building a compiler, and this compiler should generate code
203 +for a system type that is different from the one on which the compiler
204 +binaries shall run on, use the option @option{--target=@var{type}} to
205 +select the type of system for which the compiler should produce code.
207 @node Sharing Defaults
208 @section Sharing Defaults
209 @@ -384,9 +468,9 @@ Use @var{dir} as the installation prefix. @ref{Installation Names}
210 for more details, including other options available for fine-tuning
211 the installation locations.
213 -@item --build=@var{type}
214 -Build for architecture @var{type}. @ref{System Type}.
215 -for more details, including other system type options.
216 +@item --host=@var{type}
217 +Build binaries for architecture @var{type}. @ref{System Types} and
218 +@ref{Building for a different system type} for more details.
220 @item --enable-@var{feature}
221 @itemx --disable-@var{feature}