Hello Christian, * Christian Rössel wrote on Thu, May 07, 2009 at 04:09:47PM CEST: > configure switches to cross-compiling mode if I call it with build != > host like in > > ./configure --build=powerpc64-unknown-linux-gnu > --host=powerpc-bgp-linux-gnu CC=bgxlc > > Can someone explain to me what implications that has for configure > checks and the build in general?
Cross compilation mode is mostly documented in the Autoconf manual (by virtue of there being little specific cross compilation support in Automake). You can search for `cross-compiling' in the manual and will find that the AC_{CHECK,PATH}_TOOL* prefer `$host-' prefixed tools when cross compilation mode is enabled, AC_CHECK_FILE* die, and several macros that otherwise employ runtime tests, specifically AC_RUN_IFELSE and the obsolete AC_TRY_RUN do "something different" in cross compilation mode. Typically, they either allow the configure.ac author to specify some action to take in this case, or hard-wire some pessimistic default case (maybe based on the value of $host). > I can see that configure says > > checking for powerpc-bgp-linux-gnu-gcc... bgxlc > > and also the checks for ar, strip, ranlib are prefixed with $host, Yes, that's the tool checks listed above. This is because the GNU toolchain (binutils, GCC) typically is installed with such `$host-' prefixes for cross tools. > On Blue Gene/P systems you usually want to use the IBM xlc compiler > instead of gcc. So you usually explicitly specify the cross-compiler via > CC=bgxlc. If I specify CC directly, is there still the need to specify > --build and --host? Yes, in order to avoid runtime tests like executing arbitrary binaries produced with the cross compiled. > Does configure behaves differently when using gcc or bgxlc? Well, most of the differences based on the name of the compiler alone are inside Libtool's macros. The "normal" Autoconf macros only do feature tests, trying out whether some action works, some program compiles, links, or executes successfully. > Is there a way to switch to normal non-cross-compiling mode by issuing > some commands in configure.ac? Adding cross_compiling=no after AC_PROG_CC would do that, but I would not recommend doing that unconditionally; after all, your users might want to use your package in a real cross compilation mode where it is simply not possible to execute binaries produced with the compiler. As we've seen in our Libtool testing, it is also not really possible to execute arbitrary binaries produced by bgxlc on the compile nodes. Hope that helps. Cheers, Ralf