This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See crosstool-NG for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Canadian build and CT_TARGET fails


On 01. aug. 2012 19:14, Yann E. MORIN wrote:
> Per-Arnold, All,
> 
> On Wednesday 01 August 2012 16:10:45 Per Arnold Blaasmo wrote:
>> On 01. aug. 2012 08:41, Per Arnold Blaasmo wrote:
>>> On 01. aug. 2012 08:39, Yann E. MORIN wrote:
>>>> On Wednesday 01 August 2012 08:31:37 Per Arnold Blaasmo wrote:
>>>>> I am trying to do a Canadian cross from:
>>>>>
>>>>> build  = x86_64-unknown-linux-gnu
>>>>> host   = i686-pc-mingw32
>>>>> target = arm-none-eabi
>>>>>
>>>>> But I in step 'Installing pass-2 core C compiler' I get:
>>>>>> [ALL  ]    arm-none-eabi-gcc -dumpspecs > tmp-specs
>>>>>> [ALL  ]    /usr/bin/bash: arm-none-eabi-gcc: command not found
>>>>
>>>> Can you send your .config please?
>>> Here it is.
>>> This is how it look s right now :-)
> 
> Ok, I was able to reproduce your issue.
> 
>> I found for GCC in gcc/Makefile.in these lines that seems to cause the
>> error:
>>
>>> # 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)
>>
>> It uses GCC_FOR _TARGET. Which is set to 'arm-non-eabi', but since we do
>> not have that one ready yet at this point it will fail unless you have
>> it in your path prebuilt.
> 
> At which point it should use the internal xgcc it just built.
> 
> Core pass-1 is only strictly needed for NPTL builds, although it does no
> harm if present for !NPTL builds. A workaround would be to always build a
> core pass-1 compiler, but I'd like to avoid this when it is not strictly
> needed, if possible.
> 
>> I found a bug on internet that indicates that it has something to do
>> with LTO, so I will try to compile without that.
> 
> Could you please share the pointer?

That pointer did not get me anywhere, but I found something else that
got me on the track.

http://comments.gmane.org/gmane.comp.gcc.help/5749

It says:
> David Meggy wrote:
>> Why is it using $(GCC_FOR_TARGET)?  This is a cross compiler, so at a
>> minimum it is going to get the line "*cross_compile:" wrong.
> 
> If we are doing a build where $(build) != $(host), then we can't use 
> ./xgcc because it will be a binary that runs on $(host), which (usually) 
> will be a binary that won't run on the build machine.  GCC_FOR_TARGET 
> however is safe, because it should have been defined to be a 
> $(build)-x-$(target) cross compiler, which will run on the build machine.
> 
> You are right about getting the cross_compile spec wrong.  Ideally we 
> shouldn't get anything else wrong.  Ports shouldn't be changing specs 
> when built as cross compilers.

So this got me looking into the code in do_cc_core_backend():

        # On bare metal and canadian build the host-compiler is used when
        # actually the build-system compiler is required. Choose the correct
        # compilers for canadian build and use the defaults on other
        # configurations.
        if [ "${CT_BARE_METAL},${CT_CANADIAN}" = "y,y" ]; then
            repair_cc="CC_FOR_BUILD=${CT_BUILD}-gcc \
                       GCC_FOR_TARGET=${CT_TARGET}-gcc"
        else
            repair_cc=""
        fi


This part sets the GCC_FOR_TARGET always when building Canadian and
Bare_Metal.

But it should not do that when building for the core compiler, nor the
build compiler. Only when building the host compiler.

If am correct, we:
1. try to build the CT_BUILD compiler by first building the core C
compiler for the build platform.

2. Use the CT_BUILD compiler to build the host compiler.

Changing that code to:
        # On bare metal and canadian build the host-compiler is used when
        # actually the build-system compiler is required. Choose the correct
        # compilers for canadian build and use the defaults on other
        # configurations.
        if [ "${CT_BARE_METAL},${CT_CANADIAN}" = "y,y" ]; then
            # If we are building the core C compiler for the build
compiler it should be on native platform
            if [ "${host}" = "${CT_BUILD}" ]; then
            	repair_cc="CC_FOR_BUILD=${CT_BUILD}-gcc"
            else
            	repair_cc="CC_FOR_BUILD=${CT_BUILD}-gcc \
                       GCC_FOR_TARGET=${CT_TARGET}-gcc"
            fi
        else
            repair_cc=""
        fi

Got be past the step of building the final compiler for build.

It is probably not the best solution, and You will probably find a
better one. But I think it pinpoints the problem.

Per A.





--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]