On Sun, 2012-01-22 at 11:59 -0800, Ian Lance Taylor wrote: > In an ordinary build, ORIGINAL_AS_FOR_TARGET will be set > to /usr/bin/as, and similarly for LD and NM. PLUGIN_LD will typically > be the same as LD. > > You said you are building a cross-compiler; make sure that you build > and install a cross-binutils first. Thanks for this; I found a silly mistake in my process and got much farther. So here is what I want to do. Maybe this is stupid. I need to generate a GCC tool suite that will run on much older versions of GNU/Linux on 32bit Intel systems (call it OLDSYS). I'm performing the builds of the tool suite on a newer GNU/Linux Intel 64bit system and I don't have a complete OLDSYS system available to use as a build machine. Finally, I want the output of the compiler, when I invoke it, to support both 32bit and 64bit Intel embedded environments (call that NEWSYS). I have a sysroot for OLDSYS, and I have another sysroot for NEWSYS. So, my thought was to first create a "cross-compiler" from whatever the native GNU/Linux system is to OLDSYS, then use that as part of a Canadian cross to get the "cross-compiler" I want: runs on OLDSYS, generates code (via a sysroot) for NEWSYS including both 32bit and 64bit. The odd thing is that these are all GNU/Linux Intel systems and so they're actually somewhat compatible, but the idea of the Canadian cross still seems valid to me... no? So I first created a cross-compiler for OLDSYS, configuring binutils (2.22) and gcc (4.6.2) with --target=OLDSYS --with-sysroot=OLDSYSROOT (and building and installing into a separate directory of course). Then I started trying to create the Canadian cross, configuring binutils and GCC with --host=OLDSYS --target=NEWSYS --with-sysroot=NEWSYSROOT. When I do this, I can see it finding the OLDSYS compiler I built previously, and binutils configures and builds fine and if I check, the resulting binary is indeed a 32bit version and runs fine on OLDSYS. And, gcc appears to be working fine, for a while. Then I get this error: OLDSYS-gcc -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -DNATIVE_CROSS \ -W [...] -DHAVE_CONFIG_H -o cpp gcc.o o [...] \ ../libcpp/libcpp.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a NEWSYS-gcc -dumpspecs > tmp-specs /bin/sh: NEWSYS-gcc: command not found Makefile:1852: recipe for target `specs' failed make[4]: *** [specs] Error 127 make[4]: Leaving directory `/usr/src/gcc/obj-base/gcc/gcc' Makefile:5279: recipe for target `all-gcc' failed make[3]: *** [all-gcc] Error 2 make[3]: Leaving directory `/usr/src/gcc/obj-base/gcc' Makefile:898: recipe for target `all' failed make[2]: *** [all] Error 2 make[2]: Leaving directory `/usr/src/gcc/obj-base/gcc' You can see that here we're trying to invoke NEWSYS-gcc which doesn't exist yet and so it's failing. Looking at gcc/Makefile I see that it's using GCC_FOR_TARGET and that it's set properly: # The GCC to use for compiling crt*.o. # Usually the one we just built. # Don't use this as a dependency--use $(GCC_PASSES). GCC_FOR_TARGET = $(STAGE_CC_WRAPPER) ./xgcc -B./ [...] ... # Dump a specs file to make -B./ read these specs over installed ones. $(SPECS): xgcc$(exeext) $(GCC_FOR_TARGET) -dumpspecs > tmp-specs mv tmp-specs $(SPECS) That looks right: it uses ./xgcc. However, in the top-level makefile I see this: # If GCC_FOR_TARGET is not overriden on the command line, then this # variable is passed down to the gcc Makefile, where it is used to # build libgcc2.a. We define it here so that it can itself be # overridden on the command line. GCC_FOR_TARGET=$(STAGE_CC_WRAPPER) NEWSYS-gcc And, we pass this values down to the sub-makes on the command line (via the $(EXTRA_GCC_FLAGS) variable) which overrides the settings in those makefiles. I don't know how this got here. I didn't set GCC_FOR_TARGET myself; just those configure flags. It's not in my environment. When configure goes looking for these binaries it clearly realizes they're not there (from the top-level config.log): configure:9916: checking for NEWSYS-gcc configure:9946: result: no (along with all the other tools: NEWSYS-ld, etc.) But then later on I see it setting all the *_FOR_TARGET values to use the NEWSYS-prefixed values. When I look at the configuration for building OLDSYS (a straightforward cross-compile), the top-level Makefile also sets GCC_FOR_TARGET but it uses this value, which works OK: GCC_FOR_TARGET=$(STAGE_CC_WRAPPER) $$r/$(HOST_SUBDIR)/gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/ Why did my other configure decide to use something different? Any ideas on where to look? Thanks!