build = where am I compiling the compiler, host = where the compiler will run, target = what code will the compiler produce.
So, build is the machine you're building on (no change there), host is the machine you're building for (the target libraries are built for the target, so host is the target you specified), and target doesn't apply (because you're not building a compiler, you're building libraries).
$CC is always the target compiler. If you ever see $HOSTCC , it is a manual addition by the developer of the package you are looking at. --host specifies on what host type the produced program is intended to be run on.
If host and target are the same, but build is different, you are using a cross-compiler to build a native for a different system. Some people call this a host-x-host, crossed native, or cross-built native.
As noted in this blog post and alluded to in the GCC Configure Terms, --target
only applies when you are compiling toolchains. When you are doing normal cross-compilation of a library or binary you use
--build=the architecture of the build machine
--host=the architecture that you want the file to run on
However, when you are building toolchains, things can get more complicated. I think that the following is correct (though I can't say I've ever manually compiled a cross-debugger):
Lets say that you have:
You would configure and build your debugging server (eg gdbserver) to run on your embedded device with
./configure --build=powerpc --host=mips
so that you could putty on to your embedded device and run "gdbserver :1234 a.out" to start debugging and listen on port 1234.
You would then build your debugging client (which connects to and controls the gdbserver) with
./configure --build=powerpc --host=i686 --target=mips
which you would copy to your x86 laptop so that in the field you could run "gdbclient embedded.device:1234" in order to debug your a.out program.
This all applies to compilers too for which you might want to look at the GCC link above or this section about the Canadian cross compile.
Also note that, in practice, you might not see build, host or target specified because, according to this Autoconf manual page, "target defaults to host, host to build, and build to the result of config.guess."
In a word, build the code on --build
, run it on --host
with --target
architecture environment.
Note: Argument --target
makes sense only when building compiler (e.g. GCC). When running configure
before building GCC:
--build
: the machine you are building on--host
: the machine you are building for--target
: the machine that GCC will produce binary forFrom the GCC documentation (Host/Target specific installation notes):
If build, host, and target are all the same, this is called a native. If build and host are the same but target is different, this is called a cross. If build, host, and target are all different this is called a canadian (for obscure reasons dealing with Canada's political party and the background of the person working on the build at that time). If host and target are the same, but build is different, you are using a cross-compiler to build a native for a different system. Some people call this a host-x-host, crossed native, or cross-built native. If build and target are the same, but host is different, you are using a cross compiler to build a cross compiler that produces code for the machine you're building on. This is rare, so there is no common way of describing it. There is a proposal to call this a crossback.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With