fix multilib build problem

Nathan Sidwell
Tue Apr 24 16:18:00 GMT 2007

In building an m68k-elf newlib I hit a multilib problem where configure 
complains about a cached value changing value:

configure: loading cache .././config.cache
configure: error: `CC' has changed since the previous run:
configure:   former value:  m68k-elf-gcc 
-B/home/nathan/newlib/m68k-elf/m68k-elf/m68000/newlib/ -isystem 
/home/nathan/newlib/m68k-elf/m68k-elf/m68000/newlib/targ-include -isystem 
/home/nathan/newlib/src/newlib/libc/include  -m68000
configure:   current value: m68k-elf-gcc 
-B/home/nathan/newlib/m68k-elf/m68k-elf/m68000/newlib/ -isystem 
/home/nathan/newlib/m68k-elf/m68k-elf/m68000/newlib/targ-include -isystem 
/home/nathan/newlib/src/newlib/libc/include -m68000
configure: error: changes in the environment can compromise the build
configure: error: run `make distclean' and/or `rm .././config.cache' and start over
configure: error: /bin/sh '../../../../../src/newlib/libc/configure' failed for libc
make[1]: *** [configure-target-newlib] Error 1
make[1]: Leaving directory `/home/nathan/newlib/m68k-elf'

As you can see the original CC value has two spaces just before the -m68000 
multilib.  I guess that duplicate space is getting stripped during some echo, 
but I didn't look very hard for that.  Instead I worked on having 
not produce the double space.

The spacing arises from two causes.
1) the code to produce the multilib options, produces a leading space:
     # find compiler flag corresponding to ${ml_dir}
     for i in `${CC-gcc} --print-multi-lib 2>/dev/null`; do
       dir=`echo $i | sed -e 's/;.*$//'`
       if [ "${dir}" = "${ml_dir}" ]; then
         flags=`echo $i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`
  (that 's/@/ -/g' sed command)

2) the code to generate the processed CC_ value gives a trailing space:
	CC_=$CC' '
	for arg in ${CC}; do
	  case $arg in
	    CC_="${CC_}"`echo "X${arg}" | sed -n 
"s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n 
"s/X-[BIL]${popdir_rx}\\(.*\\)/\1/p"`' ' ;;
	    CC_="${CC_}"`echo "X${arg}" | sed -n 
"s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n 
"s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
	    CC_="${CC_}${arg} " ;;

This patch changes (2) to not have a trailing space.  We'll get a leading space 
for the second alternative, but that appears harmless.

With that I was able to build a complete set of m68k multilibs. ok?

I'll see about pushing this patch to GCC.

Nathan Sidwell    ::   ::         CodeSourcery    ::

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: all.diff
URL: <>

More information about the Newlib mailing list