(This file was generated by makeinfo and splitinfo.gawk.)
(Released under the old-style GNU documentation license;
 see sources or other output files for full text.)

8 Cross compilation
*******************

In a cross compilation a "build" system is used to create binaries to be
executed on a "host" system with different hardware and/or operating
system.

   In simple cases, the build system can execute binaries for the host
system.  This typically occurs for bi-arch systems where, e.g.,
'i386-linux' binaries can run on 'x86_64-linux' systems and 'win32'
binaries can run on 'win64' systems.  Although sometimes called "native
cross", technically this is not cross compilation at all.  In most such
cases it suffices to specify suitable compiler flags.  It might be
useful to add the configure option '--build=HOST' to get the correct
canonical host name, but note that this should _not_ be '--host=HOST'
(*note (autoconf)Hosts and Cross-Compilation::).

   In order to build, e.g., 32-bit binaries with 'clang' on a 64-bit
MacOSX system one could use:

     TL_BUILD_ENV="CC='clang -arch i386' \
       CXX='clang++ -arch i386' \
       OBJCXX='clang++ -arch i386'" \
       ./Build --build=i386-apple-darwin

8.1 Cross configuring
=====================

In a standard cross compilation, binaries for the host system cannot
execute on the build system and it is necessary to specify the configure
options '--host=HOST' and '--build=BUILD' with two different values.

   Building binaries requires suitable "cross" tools, e.g., compiler,
linker, and archiver, and perhaps a "cross" version of 'pkg-config' and
similar to locate host system libraries.  Autoconf expects that these
cross tools are given by their usual variables or found under their
usual name prefixed with 'HOST-'.  Here a list of such tools and
corresponding variables:

     ar                AR
     freetype-config   FT2_CONFIG
     g++               CXX
     gcc               CC
     icu-config        ICU_CONFIG
     objdump           OBJDUMP
     pkg-config        PKG_CONFIG
     ranlib            RANLIB
     strip             STRIP

In order to, e.g., build 'mingw32' binaries on 'x86_64-linux' with a
cross compiler found as 'i386-pc-mingw32-gcc' one would specify

     --host=i386-pc-mingw32 --build=x86_64-linux-gnu

or perhaps

     --host=mingw32 --build=x86_64-linux CC=i386-pc-mingw32-gcc

but this latter, especially, might require adding 'CXX' and others.

   Configure arguments such as 'CFLAGS=...' refer to the cross compiler.
If necessary, you can specify compilers and flags for the few auxiliary
C and C++ programs required for the build process as configure arguments

     BUILDCC=...
     BUILDCPPFLAGS=...
     BUILDCFLAGS=...
     BUILDCXX=...
     BUILDCXXFLAGS=...
     BUILDLDFLAGS=...

8.2 Cross problems
==================

The fact that binaries for the host system cannot be executed on the
build system causes some problems.

   One problem is that configure tests using 'AC_RUN_IFELSE' can compile
and link the test program but cannot execute it.  Such tests should be
avoided if possible and otherwise must supply a pessimistic test result.

   Another problem arises if the build process must execute some
(auxiliary or installable) programs.  Auxiliary programs can be placed
into a subdirectory that is configured natively as is done for
'texk/web2c/web2c', 'texk/dvipsk/squeeze', and 'texk/xdvik/squeeze'.
The module 'libs/freetype2' uses the value of 'CC_BUILD', 'BUILD-gcc',
'gcc', or 'cc' as the compiler for the auxiliary program.

   The situation for installable programs needed by the build process is
somewhat different.  A rather expensive possibility, chosen for the ICU
libraries in module 'libs/icu', is to first compile natively for the
build system and in a second step to use these (uninstalled) programs
during the cross compilation.

   This approach would also be possible for the tools such as 'tangle'
used in the module 'texk/web2c' to build the WEB programs, but that
would require first building a native 'kpathsea' library.  To avoid this
complication, cross compilation of the WEB or CWEB programs requires
sufficiently recent installed versions of 'tangle', 'ctangle',
'otangle', and 'tie'.

   Building 'xindy' requires running the host system 'clisp' binary,
thus cross compilation is not possible.

