diff mbox

[U-Boot] Build failures with older toolchain

Message ID B85A65D85D7EB246BE421B3FB0FBB5930247AFD2A0@dbde02.ent.ti.com
State Rejected, archived
Headers show

Commit Message

Sanjeev Premi Nov. 30, 2010, 2:25 p.m. UTC
> -----Original Message-----
> From: u-boot-bounces@lists.denx.de 
> [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Premi, Sanjeev
> Sent: Monday, November 29, 2010 8:38 PM
> To: Wolfgang Denk
> Cc: u-boot@lists.denx.de
> Subject: Re: [U-Boot] Build failures with older toolchain
> 

[snip]...[snip]

> > >
> > >      I am process of downloading the 2009q3 version from 
> > codesourcery
> > >      Albert mentioned he is using it. Are you on the same 
> version as
> > >      well?
> > 
> > No, I'm using ELDk 4.2
> 
> [sp] Okay, so I downloaded both 2009-q3 and 2010.09-50 versions of the
>      Codesourcery Lite edition.
>      
>      There is no difference in the observations between 
> 2009q3 and 2010q1.
> 
[sp] I have been able to narrow down the problem to one variable defined
     in board/ti/evm.c - omap3_evm_version - declared as:
      static u8 omap3_evm_version;

     Any attempt to assign value this variable in omap3_evm_get_revision()
     leads to the linker error I noted with Codesourcery 2010q1-202.
     
     With 2009q1-203, definition of variable itself is sufficient to cause
     the linker error.

     I have pasted a patch below that constructs the testcase I have created
     to explain these observations:
     1) When macros both _EXCLUDE_ME_1 and _EXCLUDE_ME_2 are undefined, the
        problem is - as described.

     2) When only macro _EXCLUDE_ME_1 is defined, the compilation succeeds
        with Codesourcery 2010q1-202; but fails with 2009q1-203.

     3) When both macros _EXCLUDE_ME_1 and _EXCLUDE_ME_2 are defined, the
        compilation succeeds with both codesourcery versions.

     OMAP3EVM is obviously not the only file using statics. I see their usage
     in many files including OMAP3Beagle as well - one reason I did not even
     suspect this to be problem.

     I haven't yet been able to conclude the cause of failure - but appears
     to be related to handling of static variables across compiler versions.
     Still need to investigate further on this...

     Board revision needs to be detected early during initialization. How is
     this handled for other boards? (I am currently trying to browse non-omap
     boards for pointers). Any quick suggestions would be helpful.

[patch]
[/patch]

[snip]
Removed my observations for Codesourcery 2010.09-50.
Did not get chance to look at them so far...
[/snip]

Best regards,
Sanjeev

Comments

Dirk Behme Nov. 30, 2010, 4:44 p.m. UTC | #1
On 30.11.2010 15:25, Premi, Sanjeev wrote:
>> -----Original Message-----
>> From: u-boot-bounces@lists.denx.de
>> [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Premi, Sanjeev
>> Sent: Monday, November 29, 2010 8:38 PM
>> To: Wolfgang Denk
>> Cc: u-boot@lists.denx.de
>> Subject: Re: [U-Boot] Build failures with older toolchain
>>
>
> [snip]...[snip]
>
>>>>
>>>>       I am process of downloading the 2009q3 version from
>>> codesourcery
>>>>       Albert mentioned he is using it. Are you on the same
>> version as
>>>>       well?
>>>
>>> No, I'm using ELDk 4.2
>>
>> [sp] Okay, so I downloaded both 2009-q3 and 2010.09-50 versions of the
>>       Codesourcery Lite edition.
>>
>>       There is no difference in the observations between
>> 2009q3 and 2010q1.
>>
> [sp] I have been able to narrow down the problem to one variable defined
>       in board/ti/evm.c - omap3_evm_version - declared as:
>        static u8 omap3_evm_version;
>
>       Any attempt to assign value this variable in omap3_evm_get_revision()
>       leads to the linker error I noted with Codesourcery 2010q1-202.
>
>       With 2009q1-203, definition of variable itself is sufficient to cause
>       the linker error.

Maybe CCing Codesourcery's mailing list

http://www.codesourcery.com/archives/arm-gnu-discuss/maillist.html

could help, too? At least it's worth a try?

Dirk

>       I have pasted a patch below that constructs the testcase I have created
>       to explain these observations:
>       1) When macros both _EXCLUDE_ME_1 and _EXCLUDE_ME_2 are undefined, the
>          problem is - as described.
>
>       2) When only macro _EXCLUDE_ME_1 is defined, the compilation succeeds
>          with Codesourcery 2010q1-202; but fails with 2009q1-203.
>
>       3) When both macros _EXCLUDE_ME_1 and _EXCLUDE_ME_2 are defined, the
>          compilation succeeds with both codesourcery versions.
>
>       OMAP3EVM is obviously not the only file using statics. I see their usage
>       in many files including OMAP3Beagle as well - one reason I did not even
>       suspect this to be problem.
>
>       I haven't yet been able to conclude the cause of failure - but appears
>       to be related to handling of static variables across compiler versions.
>       Still need to investigate further on this...
>
>       Board revision needs to be detected early during initialization. How is
>       this handled for other boards? (I am currently trying to browse non-omap
>       boards for pointers). Any quick suggestions would be helpful.
>
> [patch]
> diff --git a/board/ti/evm/evm.c b/board/ti/evm/evm.c
> index 09d14f7..e766355 100644
> --- a/board/ti/evm/evm.c
> +++ b/board/ti/evm/evm.c
> @@ -37,15 +37,30 @@
>   #include<asm/mach-types.h>
>   #include "evm.h"
>
> +/* #define _EXCLUDE_ME_1 */	/* Uncomment - works with 2010q1 only */
> +/* #define _EXCLUDE_ME_2 */	/* Uncomment - works with 2009q3 as well */
> +
> +#if !defined(_EXCLUDE_ME_2)
>   static u8 omap3_evm_version;
> +#endif
>
>   u8 get_omap3_evm_rev(void)
>   {
> +#ifdef _EXCLUDE_ME_2
> +	return OMAP3EVM_BOARD_GEN_1; /* Debugging: Don't use the variable */
> +#else
>   	return omap3_evm_version;
> +#endif
> +
>   }
>
>   static void omap3_evm_get_revision(void)
>   {
> +#ifdef _EXCLUDE_ME_COMPLETELY_
> +	/*
> +	 * Original code in the function is being removed completely to reduce
> +	 * scope of the debug exercise.
> +	 */
>   #if defined(CONFIG_CMD_NET)
>   	/*
>   	 * Board revision can be ascertained only by identifying
> @@ -80,6 +95,20 @@ static void omap3_evm_get_revision(void)
>   	omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
>   #endif
>   #endif	/* CONFIG_CMD_NET */
> +
> +#else
> +	/*
> +	 * Dummy implementation of function just for testing
> +	 */
> +
> +#if !defined(_EXCLUDE_ME_1)&&  !defined(_EXCLUDE_ME_2)
> +	/*
> +	 * Dummy assignment just for testing
> +	 */
> +	omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
> +#endif
> +
> +#endif	/* _EXCLUDE_ME_COMPLETELY_ */
>   }
>
>   #ifdef CONFIG_USB_OMAP3
> [/patch]
>
> [snip]
> Removed my observations for Codesourcery 2010.09-50.
> Did not get chance to look at them so far...
> [/snip]
>
> Best regards,
> Sanjeev
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>
Sanjeev Premi Nov. 30, 2010, 6:23 p.m. UTC | #2
> -----Original Message-----
> From: Dirk Behme [mailto:dirk.behme@googlemail.com] 
> Sent: Tuesday, November 30, 2010 10:15 PM
> To: Premi, Sanjeev
> Cc: u-boot@lists.denx.de
> Subject: Re: [U-Boot] Build failures with older toolchain
> 
> On 30.11.2010 15:25, Premi, Sanjeev wrote:
> >> -----Original Message-----
> >> From: u-boot-bounces@lists.denx.de
> >> [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Premi, Sanjeev
> >> Sent: Monday, November 29, 2010 8:38 PM
> >> To: Wolfgang Denk
> >> Cc: u-boot@lists.denx.de
> >> Subject: Re: [U-Boot] Build failures with older toolchain
> >>
> >
> > [snip]...[snip]
> >
> >>>>
> >>>>       I am process of downloading the 2009q3 version from
> >>> codesourcery
> >>>>       Albert mentioned he is using it. Are you on the same
> >> version as
> >>>>       well?
> >>>
> >>> No, I'm using ELDk 4.2
> >>
> >> [sp] Okay, so I downloaded both 2009-q3 and 2010.09-50 
> versions of the
> >>       Codesourcery Lite edition.
> >>
> >>       There is no difference in the observations between
> >> 2009q3 and 2010q1.
> >>
> > [sp] I have been able to narrow down the problem to one 
> variable defined
> >       in board/ti/evm.c - omap3_evm_version - declared as:
> >        static u8 omap3_evm_version;
> >
> >       Any attempt to assign value this variable in 
> omap3_evm_get_revision()
> >       leads to the linker error I noted with Codesourcery 
> 2010q1-202.
> >
> >       With 2009q1-203, definition of variable itself is 
> sufficient to cause
> >       the linker error.
> 
> Maybe CCing Codesourcery's mailing list
> 
> http://www.codesourcery.com/archives/arm-gnu-discuss/maillist.html
> 
> could help, too? At least it's worth a try?

I was thinking of same - only after we understand if there isn't
something we are, possibly, missing in changes to linker scripts.

> 
> Dirk
> 
> >       I have pasted a patch below that constructs the 
> testcase I have created
> >       to explain these observations:
> >       1) When macros both _EXCLUDE_ME_1 and _EXCLUDE_ME_2 
> are undefined, the
> >          problem is - as described.
> >
> >       2) When only macro _EXCLUDE_ME_1 is defined, the 
> compilation succeeds
> >          with Codesourcery 2010q1-202; but fails with 2009q1-203.
> >
> >       3) When both macros _EXCLUDE_ME_1 and _EXCLUDE_ME_2 
> are defined, the
> >          compilation succeeds with both codesourcery versions.
> >
> >       OMAP3EVM is obviously not the only file using 
> statics. I see their usage
> >       in many files including OMAP3Beagle as well - one 
> reason I did not even
> >       suspect this to be problem.
> >
> >       I haven't yet been able to conclude the cause of 
> failure - but appears
> >       to be related to handling of static variables across 
> compiler versions.
> >       Still need to investigate further on this...
> >
> >       Board revision needs to be detected early during 
> initialization. How is
> >       this handled for other boards? (I am currently trying 
> to browse non-omap
> >       boards for pointers). Any quick suggestions would be helpful.
> >
> > [patch]
> > diff --git a/board/ti/evm/evm.c b/board/ti/evm/evm.c
> > index 09d14f7..e766355 100644
> > --- a/board/ti/evm/evm.c
> > +++ b/board/ti/evm/evm.c
> > @@ -37,15 +37,30 @@
> >   #include<asm/mach-types.h>
> >   #include "evm.h"
> >
> > +/* #define _EXCLUDE_ME_1 */	/* Uncomment - works 
> with 2010q1 only */
> > +/* #define _EXCLUDE_ME_2 */	/* Uncomment - works 
> with 2009q3 as well */
> > +
> > +#if !defined(_EXCLUDE_ME_2)
> >   static u8 omap3_evm_version;
> > +#endif
> >
> >   u8 get_omap3_evm_rev(void)
> >   {
> > +#ifdef _EXCLUDE_ME_2
> > +	return OMAP3EVM_BOARD_GEN_1; /* Debugging: Don't use 
> the variable */
> > +#else
> >   	return omap3_evm_version;
> > +#endif
> > +
> >   }
> >
> >   static void omap3_evm_get_revision(void)
> >   {
> > +#ifdef _EXCLUDE_ME_COMPLETELY_
> > +	/*
> > +	 * Original code in the function is being removed 
> completely to reduce
> > +	 * scope of the debug exercise.
> > +	 */
> >   #if defined(CONFIG_CMD_NET)
> >   	/*
> >   	 * Board revision can be ascertained only by identifying
> > @@ -80,6 +95,20 @@ static void omap3_evm_get_revision(void)
> >   	omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
> >   #endif
> >   #endif	/* CONFIG_CMD_NET */
> > +
> > +#else
> > +	/*
> > +	 * Dummy implementation of function just for testing
> > +	 */
> > +
> > +#if !defined(_EXCLUDE_ME_1)&&  !defined(_EXCLUDE_ME_2)
> > +	/*
> > +	 * Dummy assignment just for testing
> > +	 */
> > +	omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
> > +#endif
> > +
> > +#endif	/* _EXCLUDE_ME_COMPLETELY_ */
> >   }
> >
> >   #ifdef CONFIG_USB_OMAP3
> > [/patch]
> >
> > [snip]
> > Removed my observations for Codesourcery 2010.09-50.
> > Did not get chance to look at them so far...
> > [/snip]
> >
> > Best regards,
> > Sanjeev
> > _______________________________________________
> > U-Boot mailing list
> > U-Boot@lists.denx.de
> > http://lists.denx.de/mailman/listinfo/u-boot
> >
> 
>
Sanjeev Premi Dec. 1, 2010, 2:56 p.m. UTC | #3
> -----Original Message-----
> From: u-boot-bounces@lists.denx.de 
> [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Premi, Sanjeev
> Sent: Tuesday, November 30, 2010 7:56 PM
> To: u-boot@lists.denx.de
> Subject: Re: [U-Boot] Build failures with older toolchain
> 
> > -----Original Message-----
> > From: u-boot-bounces@lists.denx.de 
> > [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Premi, Sanjeev
> > Sent: Monday, November 29, 2010 8:38 PM
> > To: Wolfgang Denk
> > Cc: u-boot@lists.denx.de
> > Subject: Re: [U-Boot] Build failures with older toolchain
> > 
> 
> [snip]...[snip]
> 
> > > >
> > > >      I am process of downloading the 2009q3 version from 
> > > codesourcery
> > > >      Albert mentioned he is using it. Are you on the same 
> > version as
> > > >      well?
> > > 
> > > No, I'm using ELDk 4.2
> > 
> > [sp] Okay, so I downloaded both 2009-q3 and 2010.09-50 
> versions of the
> >      Codesourcery Lite edition.
> >      
> >      There is no difference in the observations between 
> > 2009q3 and 2010q1.
> > 

[snip]...[snip]

There were some good patches posted recently esp the bss_debug
tool and fix for ARM relocation from Andreas. Applied them in
order to get more information.

In addition, added print indicating the function being called
in for (init_funcptr= ....) loop within board_init_f().

Also added a print in the function omap3_evm_get_revision() just
to see if it ever gets called in due to incorrect sequencing.

I could confirm that functions in init_sequence[] are called
and omap3_evm_get_revision() is not called in this sequence.

When everything failed, I went back to the u-boot.lds and
changed the way overlay is defined.

...AND PROBLEM SEEMS TO BE SOLVED!

I can now compile u-boot with both 2009q1 and 2010q1 without
any error. (yet to try with 2010.09)

To verify, I wanted to do a before-and-after comparison but
couldn't have done for the omap3_evm - used omap3_beagle instead.

I haven't yet tried running the binary on the board; but here
are top level observations:

1) .bss and .rel.dyn are starting at same address.
2) The size of .rodata has increased. (Why? not yet spent time on?)

Sending the patch in next few mins:

~sanjeev

(Comparison: "<before" and ">after")

753c753
< .rodata         0x80035578     0x9f38
---
> .rodata         0x80035578     0x9f46
757c757
<  .rodata        0x8003571c       0xbc arch/arm/lib/libarm.o
---

=== [contents deleted] ===

< .u_boot_cmd     0x80041aac      0x658
---
> .u_boot_cmd     0x80041abc      0x658

=== [contents deleted] ===

967,968c967,973
< .rel.dyn        0x80042104     0x5af0
<                 0x80042104                __rel_dyn_start = .
---
> .dynsym         0x80042114       0xa0
>                 0x80042114                __dynsym_start = .
>  *(.dynsym)
>  .dynsym        0x80042114       0xa0 arch/arm/cpu/armv7/start.o
> 
> .rel.dyn        0x800421b4     0x5af0
>                 0x800421b4                __rel_dyn_start = .

=== [contents deleted] ===

984,985c986,987
< .bss            0x80042104    0x31ba8
<                 0x80042104                __bss_start = .
---
> .bss            0x800421b4    0x31bb4 load address 0x80047ca4
>                 0x80073d68                __bss_start = .

=== [contents deleted] ===

< .dynbss         0x80073cac        0x0
---
> .dynbss         0x80073d68        0x0 load address 0x80079858
Albert ARIBAUD Dec. 1, 2010, 3:02 p.m. UTC | #4
Le 01/12/2010 15:56, Premi, Sanjeev a écrit :

> When everything failed, I went back to the u-boot.lds and
> changed the way overlay is defined.
>
> ...AND PROBLEM SEEMS TO BE SOLVED!

This most probably means some of the code running before relocation uses 
BSS; see below.

> I can now compile u-boot with both 2009q1 and 2010q1 without
> any error. (yet to try with 2010.09)
>
> To verify, I wanted to do a before-and-after comparison but
> couldn't have done for the omap3_evm - used omap3_beagle instead.
>
> I haven't yet tried running the binary on the board; but here
> are top level observations:
>
> 1) .bss and .rel.dyn are starting at same address.

This is normal and should not have any negative impact as long as code 
that runs before relocation does not access BSS -- and it should not, 
since BSS only exists after relocation.

> 2) The size of .rodata has increased. (Why? not yet spent time on?)

Weird. Can you provide all necessary info for duplicating these two builds?

> Sending the patch in next few mins:

If that's a patch to remove the overlay in the .lds, it's a Nak from me 
already.

> ~sanjeev

Amicalement,
Sanjeev Premi Dec. 1, 2010, 3:18 p.m. UTC | #5
> -----Original Message-----
> From: Albert ARIBAUD [mailto:albert.aribaud@free.fr] 
> Sent: Wednesday, December 01, 2010 8:33 PM
> To: Premi, Sanjeev
> Cc: u-boot@lists.denx.de; Wolfgang Denk
> Subject: Re: [U-Boot] Build failures with older toolchain
> 
> Le 01/12/2010 15:56, Premi, Sanjeev a écrit :
> 
> > When everything failed, I went back to the u-boot.lds and
> > changed the way overlay is defined.
> >
> > ...AND PROBLEM SEEMS TO BE SOLVED!
> 
> This most probably means some of the code running before 
> relocation uses 
> BSS; see below.
> 
> > I can now compile u-boot with both 2009q1 and 2010q1 without
> > any error. (yet to try with 2010.09)
> >
> > To verify, I wanted to do a before-and-after comparison but
> > couldn't have done for the omap3_evm - used omap3_beagle instead.
> >
> > I haven't yet tried running the binary on the board; but here
> > are top level observations:
> >
> > 1) .bss and .rel.dyn are starting at same address.
> 
> This is normal and should not have any negative impact as 
> long as code 
> that runs before relocation does not access BSS -- and it should not, 
> since BSS only exists after relocation.

[sp] Yes. This is what I wanted to confirm to ensure that relocation
     isn't breaking after the changes. In a way it was my testcase
     to see that I get similar map for omap3_beagle before and after
     making changes.
> 
> > 2) The size of .rodata has increased. (Why? not yet spent time on?)
> 
> Weird. Can you provide all necessary info for duplicating 
> these two builds?
> 
> > Sending the patch in next few mins:
> 
> If that's a patch to remove the overlay in the .lds, it's a 
> Nak from me 
> already.

[sp] No. I am not removing relocation. Do look at the patch.
     I just sent from my Linux box..

> 
> > ~sanjeev
> 
> Amicalement,
> -- 
> Albert.
>
diff mbox

Patch

diff --git a/board/ti/evm/evm.c b/board/ti/evm/evm.c
index 09d14f7..e766355 100644
--- a/board/ti/evm/evm.c
+++ b/board/ti/evm/evm.c
@@ -37,15 +37,30 @@ 
 #include <asm/mach-types.h>
 #include "evm.h"
 
+/* #define _EXCLUDE_ME_1 */	/* Uncomment - works with 2010q1 only */
+/* #define _EXCLUDE_ME_2 */	/* Uncomment - works with 2009q3 as well */
+
+#if !defined(_EXCLUDE_ME_2)
 static u8 omap3_evm_version;
+#endif
 
 u8 get_omap3_evm_rev(void)
 {
+#ifdef _EXCLUDE_ME_2
+	return OMAP3EVM_BOARD_GEN_1; /* Debugging: Don't use the variable */
+#else
 	return omap3_evm_version;
+#endif
+
 }
 
 static void omap3_evm_get_revision(void)
 {
+#ifdef _EXCLUDE_ME_COMPLETELY_
+	/*
+	 * Original code in the function is being removed completely to reduce
+	 * scope of the debug exercise.
+	 */
 #if defined(CONFIG_CMD_NET)
 	/*
 	 * Board revision can be ascertained only by identifying
@@ -80,6 +95,20 @@  static void omap3_evm_get_revision(void)
 	omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
 #endif
 #endif	/* CONFIG_CMD_NET */
+
+#else
+	/*
+	 * Dummy implementation of function just for testing
+	 */
+
+#if !defined(_EXCLUDE_ME_1) && !defined(_EXCLUDE_ME_2)
+	/*
+	 * Dummy assignment just for testing
+	 */
+	omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
+#endif
+
+#endif	/* _EXCLUDE_ME_COMPLETELY_ */
 }
 
 #ifdef CONFIG_USB_OMAP3