newlib does not pick up the right cross-compiling gcc

Josef Wolf
Fri Feb 5 15:20:00 GMT 2010

On Fri, Feb 05, 2010 at 11:29:53AM +0100, Ralf Corsepius wrote:
> On 02/05/2010 10:47 AM, Josef Wolf wrote:
>> [ Sorry for not following up to the original thread, but I already deleted
>>    before I noticed that I have the same problem ]
>> Ralf Corsepius wrote:
>>> This means you don't have powerpc-unknown-eabi-gcc installed rsp. don't have
>>> it in $PATH.
>>> To build newlib separately from gcc (which is what you do) you need your
>>> target's<target>-gcc in $PATH
>> I have the gcc for the target (m68k-unknown-elf in my case) target installed
>> and I give both, --target=m68k-unknown-elf and --host=m68k-unknown-elf
>> options to configure, but still the native gcc is picked for compiling
>> newlib.
>> Even worse: if I explicitly specify the cross compiler with
>>    CC=/path/to/cross/bin/m68k-unknown-gcc /path/to/src/configure<more_options>
> A piece of advice: It's not a good idea to set "CC", "CFLAGS", "CXXFLAGS", 
> "AS", "LIBS" etc. when starting to get into building newlib, gcc or 
> gcc+newlib, because crossbuilding typically involves build-, host- and 
> target- compilation.
> I.e. these environment variable might not be doing what think they are 
> doing - If you know what they are doing, then there is nothing wrong in 
> setting then.

I tried this because it was suggested on this list when I reported my problem.

>> then configure complains that the compiler can not create executables. Which
>> is no surprise: the cross compiler is not meant to create executables for the
>> build machine.
>> I have posted this problem to this list a while ago, but nobody seems to have
>> an idea what might cause the problem.
> Well, your report was against newlib-1.15.0 -- An outdated and discontinued 
> version, probably nobody wants to look back into :-)

My question was not against newlib-1.15. I mentioned 1.15 because this was
the version in which the code in question was added. This code is still in
the newest version. I have tried to formulate my question in a more generic
way: What's the point of checking whether a cross compiler can create
executables? IMHO a cross compiler is not supposed to create executables.

> Anyway, let me ask you a counter question: Why do you want to run 
> "newlib/configure" ?
> The standard way to build newlib is to run the toplevel
> "configure --target=<target>" in a separate build directory or to build 
> newlib one-tree style with gcc.

I do not run newlib/configure. I do something like that:

    cd $BUILDDIR/binutils
    make install

    cd $BUILDDIR/gcc
    $GCCSRC/configure $CONFOPTS --without-headers
    make BOOT_CFLAGS="-O2 -g -fno-unit-a-time" LANGUAGES=c all-gcc
    make BOOT_CFLAGS="-O2 -g -fno-unit-a-time" LANGUAGES=c install-gcc

    cd $BUILDDIR/newlib
    $NEWLIBSRC/configure $CONFOPTS
    make install

    cd $BUILDDIR/gcc
    make clean
    $GCCSRC/configure $CONFOPTS --with-headers=$NEWLIBSRC/newlib/libc/include
    make install

So I run the toplevel configure. This works fine up to the versions I
mentioned above. If I try anything newer, I get failures again.

More information about the Newlib mailing list