public inbox for crossgcc@sourceware.org
 help / color / mirror / Atom feed
* Canadian build and CT_TARGET fails
@ 2012-08-01  6:31 Per Arnold Blaasmo
  2012-08-01  6:40 ` Yann E. MORIN
  0 siblings, 1 reply; 11+ messages in thread
From: Per Arnold Blaasmo @ 2012-08-01  6:31 UTC (permalink / raw)
  To: crossgcc

Hi,
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
> [ERROR]    make[1]: *** [specs] Error 127
> [ALL  ]    make[1]: Leaving directory
> `/home/pablaasmo/tmp/ct-ng-build-1.15.3/.build/arm-none-eabi/build/build-cc-core-pass-2/gcc'
> [ERROR]  
> [ERROR]  >>
> [ERROR]  >>  Build failed in step 'Installing pass-2 core C compiler'
> [ERROR]  >>        called in step '(top-level)'
> [ERROR]  >>
> [ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@172]
> [ERROR]  >>        called from:
> do_cc_core_backend[scripts/build/cc/gcc.sh@429]
> [ERROR]  >>        called from:
> do_cc_core_pass_2[scripts/build/cc/gcc.sh@145]
> [ERROR]  >>        called from: main[scripts/crosstool-NG.sh@598]

Which tells be it needs the 'arm-non-eabi-gcc' executable for the
build-server.
But looking at the steps in 'steps.mk':
> CT_STEPS := libc_check_config   \
>             gmp_for_build       \
>             mpfr_for_build      \
>             ppl_for_build       \
>             cloog_for_build     \
>             mpc_for_build       \
>             libelf_for_build    \
>             binutils_for_build  \
>             elf2flt_for_build   \
>             gmp_for_host        \
>             mpfr_for_host       \
>             ppl_for_host        \
>             cloog_for_host      \
>             mpc_for_host        \
>             libelf_for_host     \
>             binutils_for_host   \
>             elf2flt_for_host    \
>             sstrip_for_host     \
>             cc_core_pass_1      \
>             kernel_headers      \
>             libc_start_files    \
>             cc_core_pass_2      \
>             libc                \
>             cc_for_build        \
>             cc_for_host         \
>             libc_finish         \
>             libelf_for_target   \
>             binutils_for_target \
>             debug               \
>             test_suite          \
>             finish              \

It seems like cc_for_build is built after cc_core_pass_2.

I think that in gcc.sh the code to handle this is:
>         # 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

But since i do not have a build-system compiler for target yet, this can
not work?

Am I correct?

Regards
Per A.


-- 
Per Arnold Blåsmo
Senior Design Engineer, Atmel Norway

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Canadian build and CT_TARGET fails
  2012-08-01  6:31 Canadian build and CT_TARGET fails Per Arnold Blaasmo
@ 2012-08-01  6:40 ` Yann E. MORIN
  2012-08-01  6:41   ` Per Arnold Blaasmo
  0 siblings, 1 reply; 11+ messages in thread
From: Yann E. MORIN @ 2012-08-01  6:40 UTC (permalink / raw)
  To: crossgcc, Per-Arnold.Blaasmo

Per-Arnold, All,

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?

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software  Designer | \ / CAMPAIGN     |   ^                |
| --==< O_o >==-- '------------.-------:  X  AGAINST      |  /e\  There is no  |
| http://ymorin.is-a-geek.org/ | (*_*) | / \ HTML MAIL    |  """  conspiracy.  |
'------------------------------'-------'------------------'--------------------'

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Canadian build and CT_TARGET fails
  2012-08-01  6:40 ` Yann E. MORIN
@ 2012-08-01  6:41   ` Per Arnold Blaasmo
  2012-08-01 14:11     ` Per Arnold Blaasmo
  0 siblings, 1 reply; 11+ messages in thread
From: Per Arnold Blaasmo @ 2012-08-01  6:41 UTC (permalink / raw)
  To: Yann E. MORIN; +Cc: crossgcc

[-- Attachment #1: Type: text/plain, Size: 585 bytes --]

On 01. aug. 2012 08:39, Yann E. MORIN wrote:
> Per-Arnold, All,
> 
> 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?
> 
> Regards,
> Yann E. MORIN.
> 
Here it is.
This is how it look s right now :-)

Per A.

[-- Attachment #2: .config --]
[-- Type: application/x-config, Size: 9436 bytes --]

[-- Attachment #3: Type: text/plain, Size: 71 bytes --]

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Canadian build and CT_TARGET fails
  2012-08-01  6:41   ` Per Arnold Blaasmo
@ 2012-08-01 14:11     ` Per Arnold Blaasmo
  2012-08-01 17:14       ` Yann E. MORIN
  0 siblings, 1 reply; 11+ messages in thread
From: Per Arnold Blaasmo @ 2012-08-01 14:11 UTC (permalink / raw)
  To: Yann E. MORIN; +Cc: crossgcc

On 01. aug. 2012 08:41, Per Arnold Blaasmo wrote:
> On 01. aug. 2012 08:39, Yann E. MORIN wrote:
>> Per-Arnold, All,
>>
>> 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?
>>
>> Regards,
>> Yann E. MORIN.
>>
> Here it is.
> This is how it look s right now :-)
> 
> Per A.
> 

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.

I found a bug on internet that indicates that it has something to do
with LTO, so I will try to compile without that.


Per A.


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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Canadian build and CT_TARGET fails
  2012-08-01 14:11     ` Per Arnold Blaasmo
@ 2012-08-01 17:14       ` Yann E. MORIN
  2012-08-02  8:30         ` Per Arnold Blaasmo
  0 siblings, 1 reply; 11+ messages in thread
From: Yann E. MORIN @ 2012-08-01 17:14 UTC (permalink / raw)
  To: crossgcc, per-arnold.blaasmo

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?

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Canadian build and CT_TARGET fails
  2012-08-01 17:14       ` Yann E. MORIN
@ 2012-08-02  8:30         ` Per Arnold Blaasmo
  2012-08-02 22:21           ` Yann E. MORIN
  0 siblings, 1 reply; 11+ messages in thread
From: Per Arnold Blaasmo @ 2012-08-02  8:30 UTC (permalink / raw)
  To: Yann E. MORIN; +Cc: crossgcc

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Canadian build and CT_TARGET fails
  2012-08-02  8:30         ` Per Arnold Blaasmo
@ 2012-08-02 22:21           ` Yann E. MORIN
  2012-08-03  6:12             ` Per Arnold Blaasmo
  0 siblings, 1 reply; 11+ messages in thread
From: Yann E. MORIN @ 2012-08-02 22:21 UTC (permalink / raw)
  To: per-arnold.blaasmo; +Cc: crossgcc

Per-Arnold, All,

On Thursday 02 August 2012 10:29:56 Per Arnold Blaasmo wrote:
[--SNIP--]
> >> 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.

OK, now crosstool-NG always builds the core pass-1 core compiler.
I've oushed the changeset to the repos, now. Care to give it a whirl?

I'll probably do the release to morrow evening (which is a 3-day delay from
the planned schedule. Shit happens, big deal).

Thanks for the report and the digging! :-)

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Canadian build and CT_TARGET fails
  2012-08-02 22:21           ` Yann E. MORIN
@ 2012-08-03  6:12             ` Per Arnold Blaasmo
  2012-08-03  6:38               ` Per Arnold Blaasmo
  0 siblings, 1 reply; 11+ messages in thread
From: Per Arnold Blaasmo @ 2012-08-03  6:12 UTC (permalink / raw)
  To: Yann E. MORIN; +Cc: crossgcc

On 03. aug. 2012 00:20, Yann E. MORIN wrote:
> Per-Arnold, All,
> 
> On Thursday 02 August 2012 10:29:56 Per Arnold Blaasmo wrote:
> [--SNIP--]
>>>> 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.
> 
> OK, now crosstool-NG always builds the core pass-1 core compiler.
> I've oushed the changeset to the repos, now. Care to give it a whirl?
> 
> I'll probably do the release to morrow evening (which is a 3-day delay from
> the planned schedule. Shit happens, big deal).
> 
> Thanks for the report and the digging! :-)
> 
> Regards,
> Yann E. MORIN.
> 
Hi,
I had to make more changes to make it work al the way trough..
After the changes I made in gcc.sh I also had to make changes to the
libc (newlib.sh) build and add do_libc_for_build() and do_libc_for_host().

I will make a patch set in the next hour so that you can see.
I will upload it here.

Regards
Per A.

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Canadian build and CT_TARGET fails
  2012-08-03  6:12             ` Per Arnold Blaasmo
@ 2012-08-03  6:38               ` Per Arnold Blaasmo
  2012-08-03 20:58                 ` Yann E. MORIN
  0 siblings, 1 reply; 11+ messages in thread
From: Per Arnold Blaasmo @ 2012-08-03  6:38 UTC (permalink / raw)
  To: Yann E. MORIN; +Cc: crossgcc

[-- Attachment #1: Type: text/plain, Size: 1945 bytes --]

On 03. aug. 2012 08:11, Per Arnold Blaasmo wrote:
> On 03. aug. 2012 00:20, Yann E. MORIN wrote:
>> Per-Arnold, All,
>>
>> On Thursday 02 August 2012 10:29:56 Per Arnold Blaasmo wrote:
>> [--SNIP--]
>>>>> 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.
>>
>> OK, now crosstool-NG always builds the core pass-1 core compiler.
>> I've oushed the changeset to the repos, now. Care to give it a whirl?
>>
>> I'll probably do the release to morrow evening (which is a 3-day delay from
>> the planned schedule. Shit happens, big deal).
>>
>> Thanks for the report and the digging! :-)
>>
>> Regards,
>> Yann E. MORIN.
>>
> Hi,
> I had to make more changes to make it work al the way trough..
> After the changes I made in gcc.sh I also had to make changes to the
> libc (newlib.sh) build and add do_libc_for_build() and do_libc_for_host().
> 
> I will make a patch set in the next hour so that you can see.
> I will upload it here.
> 
> Regards
> Per A.
> 
> --
> For unsubscribe information see http://sourceware.org/lists.html#faq
> 
> 
> 
Here is the patch I made yesterday to get to build to work with the
attached config file.

It is Building a toolchain for:
      build  = x86_64-unknown-linux-gnu
      host   = i686-pc-mingw32
      target = arm-none-eabi
with MULTILIB enabled.

Please see trough it and see if it is OK.
I have not tested it on other configs yet.

I will do some more testing today.

NB! this patch do not include the last changes you did yesterday (3
commits I think).

Regards
Per A.

[-- Attachment #2: .config --]
[-- Type: application/x-config, Size: 9447 bytes --]

[-- Attachment #3: ct-ng-atmel-canadian-patch.diff --]
[-- Type: text/x-patch, Size: 7771 bytes --]

# HG changeset patch
# User pablaasmo
# Date 1343974985 -7200
# Branch crosstool-ng-atmel
# Node ID 83eb78ed9d01dc2322f5b6f20730a91850e123f6
# Parent  9bf1030384c048073fd8dbb330ec1135e30451d0
gcc.sh: changed handling of CANADIAN build so that correct compiler is used when building compiler for build.
<libc>.sh: added functions do_libc_for_build and dor_libc_for_host so that building newlib works in CANADIAN builds.
steps.mk: removed step libc, and replaced with libc_for_build and libc_for host

diff -r 9bf1030384c0 -r 83eb78ed9d01 scripts/build/cc/gcc.sh
--- a/scripts/build/cc/gcc.sh	Thu Aug 02 14:36:01 2012 +0200
+++ b/scripts/build/cc/gcc.sh	Fri Aug 03 08:23:05 2012 +0200
@@ -420,8 +420,13 @@
         # 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 \
+            # If we are building the core C 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
@@ -459,8 +464,15 @@
     CT_DoExecLog ALL ln -sfv "${CT_TARGET}-gcc${ext}" "${prefix}/bin/${CT_TARGET}-cc${ext}"
 
     if [ "${CT_MULTILIB}" = "y" ]; then
-        multilibs=( $( "${prefix}/bin/${CT_TARGET}-gcc" -print-multi-lib   \
-                       |tail -n +2 ) )
+    	if [ "${CT_CANADIAN}" = "y" ] && [ "${host}" != "${CT_BUILD}" ]; then
+            # If we do CANADIAN build and are building the host C compiler  
+            # we should use build platforms executables
+            multilibs=( $( "${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-gcc" -print-multi-lib   \
+                           |tail -n +2 ) )
+	 	else
+            multilibs=( $( "${prefix}/bin/${CT_TARGET}-gcc" -print-multi-lib   \
+                           |tail -n +2 ) )
+        fi
         if [ ${#multilibs[@]} -ne 0 ]; then
             CT_DoLog EXTRA "gcc configured with these multilibs (besides the default):"
             for i in "${multilibs[@]}"; do
@@ -540,6 +552,14 @@
         final_backend=do_cc_backend
     fi
 
+	# We can not use system zlib from build on host when
+	# doing a CANADIAN build unless we also build it first
+	# for the host.
+    if [ "${CT_CANADIAN}" = "y" ]; then
+	CT_DoStep INFO "Unsetting CT_CC_GCC_SYSTEM_ZLIB"
+        unset CT_CC_GCC_SYSTEM_ZLIB
+    fi
+    
     CT_DoStep INFO "Installing final compiler"
     CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-final"
 
diff -r 9bf1030384c0 -r 83eb78ed9d01 scripts/build/libc/glibc-eglibc.sh-common
--- a/scripts/build/libc/glibc-eglibc.sh-common	Thu Aug 02 14:36:01 2012 +0200
+++ b/scripts/build/libc/glibc-eglibc.sh-common	Fri Aug 03 08:23:05 2012 +0200
@@ -60,6 +60,20 @@
     do_libc_backend libc_mode=startfiles
 }
 
+# Builds a libc for the build platform
+do_libc_for_build {
+	# Not really necessary here but for compatibility 
+	# with the api of other c-lib scripts 
+	:
+}
+
+# Builds a libc for the host platform
+do_libc_for_host {
+	# Not really necessary here but for compatibility 
+	# with the api of other c-lib scripts 
+	do_libc
+}
+
 # This function builds and install the full C library
 do_libc() {
     do_libc_backend libc_mode=final
diff -r 9bf1030384c0 -r 83eb78ed9d01 scripts/build/libc/mingw.sh
--- a/scripts/build/libc/mingw.sh	Thu Aug 02 14:36:01 2012 +0200
+++ b/scripts/build/libc/mingw.sh	Fri Aug 03 08:23:05 2012 +0200
@@ -53,6 +53,20 @@
     CT_EndStep
 }
 
+# Builds a libc for the build platform
+do_libc_for_build {
+	# Not really necessary here but for compatibility 
+	# with the api of other c-lib scripts 
+	:
+}
+
+# Builds a libc for the host platform
+do_libc_for_host {
+	# Not really necessary here but for compatibility 
+	# with the api of other c-lib scripts 
+	do_libc
+}
+
 do_libc() {
     CT_DoStep INFO "Building MinGW files"
 
diff -r 9bf1030384c0 -r 83eb78ed9d01 scripts/build/libc/newlib.sh
--- a/scripts/build/libc/newlib.sh	Thu Aug 02 14:36:01 2012 +0200
+++ b/scripts/build/libc/newlib.sh	Fri Aug 03 08:23:05 2012 +0200
@@ -52,14 +52,57 @@
     :
 }
 
+do_libc_for_build() {
+    local -a build_final_opts
+    local build_final_backend
+    
+    # In case we're canadian or cross-native, it seems that a
+    # real, complete compiler is needed?!? WTF? Sigh...
+    # Otherwise, there is nothing to do.
+    case "${CT_TOOLCHAIN_TYPE}" in
+        native|cross)   return 0;;
+    esac
+
+    build_final_opts+=( "host=${CT_BUILD}" )
+    build_final_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
+
+    CT_DoStep INFO "Installing C library for build"
+    CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-build"
+
+    do_libc "${build_final_opts[@]}"
+ 
+    CT_Popd
+    CT_EndStep
+}
+
+do_libc_for_host() {
+    local -a build_final_opts
+    local build_final_backend
+    
+    final_opts+=( "host=${CT_HOST}" )
+    final_opts+=( "prefix=${CT_PREFIX_DIR}" )
+
+    CT_DoStep INFO "Installing C library for host"
+    CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-final"
+
+    do_libc "${final_opts[@]}"
+ 
+    CT_Popd
+    CT_EndStep
+}
+
 do_libc() {
     local -a newlib_opts
+    local host
+    local prefix
+    local arg
+
+    for arg in "$@"; do
+        eval "${arg// /\\ }"
+    done
 
     CT_DoStep INFO "Installing C library"
 
-    mkdir -p "${CT_BUILD_DIR}/build-libc"
-    cd "${CT_BUILD_DIR}/build-libc"
-
     CT_DoLog EXTRA "Configuring C library"
 
     if [ "${CT_LIBC_NEWLIB_IO_C99FMT}" = "y" ]; then
@@ -102,9 +145,9 @@
     AR=${CT_TARGET}-ar                                  \
     RANLIB=${CT_TARGET}-ranlib                          \
     "${CT_SRC_DIR}/newlib-$(libc_newlib_version)/configure" \
-        --host=${CT_BUILD}                              \
+		--host=${host}                                  \
         --target=${CT_TARGET}                           \
-        --prefix=${CT_PREFIX_DIR}                       \
+		--prefix=${prefix}                              \
         "${newlib_opts[@]}"                             \
         "${CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY[@]}"
 
diff -r 9bf1030384c0 -r 83eb78ed9d01 scripts/build/libc/none.sh
--- a/scripts/build/libc/none.sh	Thu Aug 02 14:36:01 2012 +0200
+++ b/scripts/build/libc/none.sh	Fri Aug 03 08:23:05 2012 +0200
@@ -18,6 +18,14 @@
     :
 }
 
+do_libc_for_build() {
+	:
+}
+
+do_libc_for_host() {
+	:
+}
+
 do_libc() {
     :
 }
diff -r 9bf1030384c0 -r 83eb78ed9d01 scripts/build/libc/uClibc.sh
--- a/scripts/build/libc/uClibc.sh	Thu Aug 02 14:36:01 2012 +0200
+++ b/scripts/build/libc/uClibc.sh	Fri Aug 03 08:23:05 2012 +0200
@@ -154,6 +154,20 @@
     CT_EndStep
 }
 
+# Builds a libc for the build platform
+do_libc_for_build {
+	# Not really necessary here but for compatibility 
+	# with the api of other c-lib scripts 
+	:
+}
+
+# Builds a libc for the host platform
+do_libc_for_host {
+	# Not really necessary here but for compatibility 
+	# with the api of other c-lib scripts 
+	do_libc
+}
+
 # This function build and install the full uClibc
 do_libc() {
     CT_DoStep INFO "Installing C library"
diff -r 9bf1030384c0 -r 83eb78ed9d01 steps.mk
--- a/steps.mk	Thu Aug 02 14:36:01 2012 +0200
+++ b/steps.mk	Fri Aug 03 08:23:05 2012 +0200
@@ -40,8 +40,9 @@
             kernel_headers      \
             libc_start_files    \
             cc_core_pass_2      \
-            libc                \
+            libc_for_build      \
             cc_for_build        \
+            libc_for_host       \
             cc_for_host         \
             libc_finish         \
             libelf_for_target   \


[-- Attachment #4: Type: text/plain, Size: 71 bytes --]

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Canadian build and CT_TARGET fails
  2012-08-03  6:38               ` Per Arnold Blaasmo
@ 2012-08-03 20:58                 ` Yann E. MORIN
  2012-08-04 21:47                   ` Yann E. MORIN
  0 siblings, 1 reply; 11+ messages in thread
From: Yann E. MORIN @ 2012-08-03 20:58 UTC (permalink / raw)
  To: crossgcc, per-arnold.blaasmo

Per-Arnold, All,

On Friday 03 August 2012 08:37:56 Per Arnold Blaasmo wrote:
> Here is the patch I made yesterday to get to build to work with the
> attached config file.

OK, I ran your .config without the patch against the current repository,
and the core pass-1 and core pass-2 compilers built fine.

There was still an error in the final gcc that I'm ironing out. See my
comment about the C library, below.

> It is Building a toolchain for:
>       build  = x86_64-unknown-linux-gnu
>       host   = i686-pc-mingw32
>       target = arm-none-eabi
> with MULTILIB enabled.
> 
> Please see trough it and see if it is OK.
> I have not tested it on other configs yet.
> 
> I will do some more testing today.
> 
> NB! this patch do not include the last changes you did yesterday (3
> commits I think).

OK, not your fault, but this is too late for the current release, which is
now 3 days late. I'll cut the release tonight without this change.

As for the patch content:

 - I think the comments in gcc.sh are either wrong, or the code is incorrect:
   the core gcc are always built for build, not for host. In retrospect, I
   believe the comments are right, but the tests are wrong; they might work,
   but they are not testing what they should: one can not decide that
   $host == $CT_BUILD implies the core compiler; $host == $CT_BUILD is a
   _consequence_ of the core compiler.
   "A implies B", where 'A' is 'core compiler', and B is '$host == $CT_BUILD'
   does not mean tht "B implies A".

   Which means that we need to pass an option to the core backend stating
   that we actually build a core or a final compiler.

 - the "system zlib" option is here for a reason, and the comment you added
   is right: if you want to use the "system zlib", it should be built and
   installed for the host prior to build ing the canadian toolchain. If zlib
   is not present on the host, then do not choose to use the system zlib.

 - the libc_for_{host,build} looks dubious. After all, the C library that
   runs on the target is exactly the same, whether the compiler runs on
   build or on host.
   I think that the correct fix would be to build the C library before
   cc_for_build (move step 'libc' one-up). The cc_for_build already uses
   the same sysroot as the final gcc. That way, we build the C library
   only once, but install it twice.

 - the patch is space/tab mangled. In crosstool-NG, we do not use tabs, and
   we use a 4-space wide indentation.

I also have a few comments on submitting that patch:

 - please rebase your patch onto the current repository tip
 - split the patch into self-contained, semantically separated patches
 - do not forget to SoB your patches
 - send a proper Hg patchset (eg. using the patchbomb extension)
 - send mails with in-body patches, they are easier to review and comment
   upon.

(there is a nice step-by-step procedure in "docs/ C - Misc. tutorials.txt"
 section "Using Mercurial to hack crosstool-NG")

Thank you for raising all these issues, and digging in! ;-)

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Canadian build and CT_TARGET fails
  2012-08-03 20:58                 ` Yann E. MORIN
@ 2012-08-04 21:47                   ` Yann E. MORIN
  0 siblings, 0 replies; 11+ messages in thread
From: Yann E. MORIN @ 2012-08-04 21:47 UTC (permalink / raw)
  To: crossgcc; +Cc: per-arnold.blaasmo

Per-Arnold, All,

On Friday 03 August 2012 22:58:23 Yann E. MORIN wrote:
> On Friday 03 August 2012 08:37:56 Per Arnold Blaasmo wrote:
> > Here is the patch I made yesterday to get to build to work with the
> > attached config file.
[--SNIP--]
> > NB! this patch do not include the last changes you did yesterday (3
> > commits I think).
[--SNIP--]
>  - the libc_for_{host,build} looks dubious. After all, the C library that
>    runs on the target is exactly the same, whether the compiler runs on
>    build or on host.
>    I think that the correct fix would be to build the C library before
>    cc_for_build (move step 'libc' one-up). The cc_for_build already uses
>    the same sysroot as the final gcc. That way, we build the C library
>    only once, but install it twice.

Hmm, in fact, that's already the case, I mis-read the patch.
I'll investigate the issue later...

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-08-04 21:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-01  6:31 Canadian build and CT_TARGET fails Per Arnold Blaasmo
2012-08-01  6:40 ` Yann E. MORIN
2012-08-01  6:41   ` Per Arnold Blaasmo
2012-08-01 14:11     ` Per Arnold Blaasmo
2012-08-01 17:14       ` Yann E. MORIN
2012-08-02  8:30         ` Per Arnold Blaasmo
2012-08-02 22:21           ` Yann E. MORIN
2012-08-03  6:12             ` Per Arnold Blaasmo
2012-08-03  6:38               ` Per Arnold Blaasmo
2012-08-03 20:58                 ` Yann E. MORIN
2012-08-04 21:47                   ` Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).