autoconf: Hosts and Cross-Compilation
1
1 18.6.3 Hosts and Cross-Compilation
1 ----------------------------------
1
1 Based on the experience of compiler writers, and after long public
1 debates, many aspects of the cross-compilation chain have changed:
1
1 - the relationship between the build, host, and target architecture
1 types,
1
1 - the command line interface for specifying them to `configure',
1
1 - the variables defined in `configure',
1
1 - the enabling of cross-compilation mode.
1
1
1 The relationship between build, host, and target have been cleaned
1 up: the chain of default is now simply: target defaults to host, host to
1 build, and build to the result of `config.guess'. Nevertheless, in
1 order to ease the transition from 2.13 to 2.50, the following
1 transition scheme is implemented. _Do not rely on it_, as it will be
1 completely disabled in a couple of releases (we cannot keep it, as it
1 proves to cause more problems than it cures).
1
1 They all default to the result of running `config.guess', unless you
1 specify either `--build' or `--host'. In this case, the default
1 becomes the system type you specified. If you specify both, and
1 they're different, `configure' enters cross compilation mode, so it
1 doesn't run any tests that require execution.
1
1 Hint: if you mean to override the result of `config.guess', prefer
1 `--build' over `--host'.
1
1
1 For backward compatibility, `configure' accepts a system type as an
1 option by itself. Such an option overrides the defaults for build,
1 host, and target system types. The following configure statement
1 configures a cross toolchain that runs on NetBSD/alpha but generates
1 code for GNU Hurd/sparc, which is also the build platform.
1
1 ./configure --host=alpha-netbsd sparc-gnu
1
1
1 In Autoconf 2.13 and before, the variables `build', `host', and
1 `target' had a different semantics before and after the invocation of
1 `AC_CANONICAL_BUILD' etc. Now, the argument of `--build' is strictly
1 copied into `build_alias', and is left empty otherwise. After the
1 `AC_CANONICAL_BUILD', `build' is set to the canonicalized build type.
1 To ease the transition, before, its contents is the same as that of
1 `build_alias'. Do _not_ rely on this broken feature.
1
1 For consistency with the backward compatibility scheme exposed above,
1 when `--host' is specified but `--build' isn't, the build system is
1 assumed to be the same as `--host', and `build_alias' is set to that
1 value. Eventually, this historically incorrect behavior will go away.
1
1
1 The former scheme to enable cross-compilation proved to cause more
1 harm than good, in particular, it used to be triggered too easily,
1 leaving regular end users puzzled in front of cryptic error messages.
1 `configure' could even enter cross-compilation mode only because the
1 compiler was not functional. This is mainly because `configure' used
1 to try to detect cross-compilation, instead of waiting for an explicit
1 flag from the user.
1
1 Now, `configure' enters cross-compilation mode if and only if
1 `--host' is passed.
1
1 That's the short documentation. To ease the transition between 2.13
1 and its successors, a more complicated scheme is implemented. _Do not
1 rely on the following_, as it will be removed in the near future.
1
1 If you specify `--host', but not `--build', when `configure'
1 performs the first compiler test it tries to run an executable produced
1 by the compiler. If the execution fails, it enters cross-compilation
1 mode. This is fragile. Moreover, by the time the compiler test is
1 performed, it may be too late to modify the build-system type: other
1 tests may have already been performed. Therefore, whenever you specify
1 `--host', be sure to specify `--build' too.
1
1 ./configure --build=i686-pc-linux-gnu --host=m68k-coff
1
1 enters cross-compilation mode. The former interface, which consisted
1 in setting the compiler to a cross-compiler without informing
1 `configure' is obsolete. For instance, `configure' fails if it can't
1 run the code generated by the specified compiler if you configure as
1 follows:
1
1 ./configure CC=m68k-coff-gcc
1