Patchwork [U-Boot,1/2] tegra2: Always build with USE_PRIVATE_LIBGCC=yes.

login
register
mail settings
Submitter Thierry Reding
Date Nov. 17, 2011, 10:04 a.m.
Message ID <1321524246-5187-2-git-send-email-thierry.reding@avionic-design.de>
Download mbox | patch
Permalink /patch/126171/
State Accepted
Commit 09743ba635be487766d959f8d86f2bdb8686ad92
Headers show

Comments

Thierry Reding - Nov. 17, 2011, 10:04 a.m.
The AVP on Tegra2 doesn't boot properly when U-Boot is linked against
the GCC provided libgcc. To work around this, always build and link
against a private libgcc for Tegra2-based boards.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
---
 arch/arm/cpu/armv7/tegra2/config.mk |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Simon Glass - Nov. 17, 2011, 11:08 p.m.
On Thu, Nov 17, 2011 at 2:04 AM, Thierry Reding
<thierry.reding@avionic-design.de> wrote:
> The AVP on Tegra2 doesn't boot properly when U-Boot is linked against
> the GCC provided libgcc. To work around this, always build and link
> against a private libgcc for Tegra2-based boards.
>
> Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>

Tested-by: Simon Glass <sjg@chromium.org>

> ---
>  arch/arm/cpu/armv7/tegra2/config.mk |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/cpu/armv7/tegra2/config.mk b/arch/arm/cpu/armv7/tegra2/config.mk
> index 8f9bdc9..2303dba 100644
> --- a/arch/arm/cpu/armv7/tegra2/config.mk
> +++ b/arch/arm/cpu/armv7/tegra2/config.mk
> @@ -29,3 +29,5 @@
>  ifdef CONFIG_TEGRA2
>  CFLAGS_arch/arm/lib/board.o += -march=armv4t
>  endif
> +
> +USE_PRIVATE_LIBGCC = yes
> --
> 1.7.7.3
>
>
Wolfgang Denk - Jan. 5, 2012, 3:50 p.m.
Dear Thierry Reding,

In message <1321524246-5187-2-git-send-email-thierry.reding@avionic-design.de> you wrote:
> The AVP on Tegra2 doesn't boot properly when U-Boot is linked against
> the GCC provided libgcc. To work around this, always build and link
> against a private libgcc for Tegra2-based boards.

I notice this patch only now, when pulling in from u-boot-arm.

I will accept this only temporarily.  Why don't you use a working tool
chain instead, or fix the one you are using?

Best regards,

Wolfgang Denk
Stephen Warren - Jan. 5, 2012, 4:53 p.m.
On 01/05/2012 08:50 AM, Wolfgang Denk wrote:
> Dear Thierry Reding,
> 
> In message <1321524246-5187-2-git-send-email-thierry.reding@avionic-design.de> you wrote:
>> The AVP on Tegra2 doesn't boot properly when U-Boot is linked against
>> the GCC provided libgcc. To work around this, always build and link
>> against a private libgcc for Tegra2-based boards.
> 
> I notice this patch only now, when pulling in from u-boot-arm.
> 
> I will accept this only temporarily.  Why don't you use a working tool
> chain instead, or fix the one you are using?

I believe the issue isn't that the toolchain is broken, but due to the
mix of multiple CPU types on Tegra, all of which run the same U-Boot binary.

U-Boot starts execution on the AVP CPU, an ARMv4(?) CPU. U-Boot then
inits the main CPUs, ARMv7 Cortex A9s, and arranges for them to continue
running U-Boot.

The libraries included in the toolchain are built for the ARMv7 CPUs,
and hence fail to operate correctly when used by the portion of U-Boot
which runs on the ARMv4 CPU, presumably due to ISA differences. IIRC,
there are overrides in the U-Boot build process such that some/all of
U-Boot is built so it'll run on ARMv4 OK, which is why using libgcc
built by U-Boot solves this.
Simon Glass - Jan. 5, 2012, 5:07 p.m.
Hi Stephen,

On Thu, Jan 5, 2012 at 8:53 AM, Stephen Warren <swarren@nvidia.com> wrote:
> On 01/05/2012 08:50 AM, Wolfgang Denk wrote:
>> Dear Thierry Reding,
>>
>> In message <1321524246-5187-2-git-send-email-thierry.reding@avionic-design.de> you wrote:
>>> The AVP on Tegra2 doesn't boot properly when U-Boot is linked against
>>> the GCC provided libgcc. To work around this, always build and link
>>> against a private libgcc for Tegra2-based boards.
>>
>> I notice this patch only now, when pulling in from u-boot-arm.
>>
>> I will accept this only temporarily.  Why don't you use a working tool
>> chain instead, or fix the one you are using?
>
> I believe the issue isn't that the toolchain is broken, but due to the
> mix of multiple CPU types on Tegra, all of which run the same U-Boot binary.
>
> U-Boot starts execution on the AVP CPU, an ARMv4(?) CPU. U-Boot then
> inits the main CPUs, ARMv7 Cortex A9s, and arranges for them to continue
> running U-Boot.
>
> The libraries included in the toolchain are built for the ARMv7 CPUs,
> and hence fail to operate correctly when used by the portion of U-Boot
> which runs on the ARMv4 CPU, presumably due to ISA differences. IIRC,
> there are overrides in the U-Boot build process such that some/all of
> U-Boot is built so it'll run on ARMv4 OK, which is why using libgcc
> built by U-Boot solves this.

Yes that's right, but actually I have never delved into exactly why.
Perhaps it is an integer divide or internal memcpy() call early in the
code. We might be able to find the offending C library code, given
enough time, and perhaps arrange not to call it. A little fragile
though.

Regards,
Simon

>
> --
> nvpublic
Wolfgang Denk - Jan. 5, 2012, 7:16 p.m.
Dear Stephen Warren,

In message <4F05D596.6030900@nvidia.com> you wrote:
>
> > I will accept this only temporarily.  Why don't you use a working tool
> > chain instead, or fix the one you are using?
> 
> I believe the issue isn't that the toolchain is broken, but due to the
> mix of multiple CPU types on Tegra, all of which run the same U-Boot binary.

When we can solve this issue with our own version of the libgcc, then
we can also solve it by using a tool chain that provides the needed
lingcc code.

> U-Boot starts execution on the AVP CPU, an ARMv4(?) CPU. U-Boot then
> inits the main CPUs, ARMv7 Cortex A9s, and arranges for them to continue
> running U-Boot.

OK, so you have to use a tool chain which provides libgcc code for
armv4t systems.  What exactly is the problem here?

> The libraries included in the toolchain are built for the ARMv7 CPUs,

SO this is not the right tool chain for the job.  Ecactly what I said.

> and hence fail to operate correctly when used by the portion of U-Boot
> which runs on the ARMv4 CPU, presumably due to ISA differences. IIRC,
> there are overrides in the U-Boot build process such that some/all of
> U-Boot is built so it'll run on ARMv4 OK, which is why using libgcc
> built by U-Boot solves this.

No, this is NOT a solution, it is a workaround for an inappropriate
toolchain.  If you want to build code for an armv4t system, you must
use a tool chain that supports it.

Best regards,

Wolfgang Denk
Wolfgang Denk - Jan. 5, 2012, 7:17 p.m.
Dear Simon Glass,

In message <CAPnjgZ2wCqF2tPWwFUdKG7y_xDeYhbFrEnqXxRJG6eU7yj9Xug@mail.gmail.com> you wrote:
> 
> > The libraries included in the toolchain are built for the ARMv7 CPUs,
> > and hence fail to operate correctly when used by the portion of U-Boot
> > which runs on the ARMv4 CPU, presumably due to ISA differences. IIRC,
> > there are overrides in the U-Boot build process such that some/all of
> > U-Boot is built so it'll run on ARMv4 OK, which is why using libgcc
> > built by U-Boot solves this.
> 
> Yes that's right, but actually I have never delved into exactly why.
> Perhaps it is an integer divide or internal memcpy() call early in the
> code. We might be able to find the offending C library code, given
> enough time, and perhaps arrange not to call it. A little fragile
> though.

That would be the totally wrong approach.  Problems should be solved
where they originate.  Here this appears to be the tool chain, which
does not provide a version of libgcc suitable for amv4t
configurations.

Best regards,

Wolfgang Denk
Stephen Warren - Jan. 5, 2012, 7:40 p.m.
On 01/05/2012 12:16 PM, Wolfgang Denk wrote:
> In message <4F05D596.6030900@nvidia.com> you wrote:
...
>> The libraries included in the toolchain are built for the ARMv7 CPUs,
> 
> SO this is not the right tool chain for the job.  Ecactly what I said.
> 
>> and hence fail to operate correctly when used by the portion of U-Boot
>> which runs on the ARMv4 CPU, presumably due to ISA differences. IIRC,
>> there are overrides in the U-Boot build process such that some/all of
>> U-Boot is built so it'll run on ARMv4 OK, which is why using libgcc
>> built by U-Boot solves this.
> 
> No, this is NOT a solution, it is a workaround for an inappropriate
> toolchain.  If you want to build code for an armv4t system, you must
> use a tool chain that supports it.

But we don't want to generate code for ARMv4 in general, but rather
ARMv7 as the toolchain does. Only a tiny part of the code needs to be
built for ARMv4, and in general we want to benefit from using ARMv7.
Wolfgang Denk - Jan. 5, 2012, 8:17 p.m.
Dear Stephen Warren,

In message <4F05FCBD.2040207@nvidia.com> you wrote:
>
> > No, this is NOT a solution, it is a workaround for an inappropriate
> > toolchain.  If you want to build code for an armv4t system, you must
> > use a tool chain that supports it.
> 
> But we don't want to generate code for ARMv4 in general, but rather

Then just turn on the ARMv4 specific options (-march=armv4t -mno-thumb
-mthumb-interwork -mtune=arm920t ???) for the files that need it.

But as soon as any of these files liks code from libgcc you have to
decide.

> ARMv7 as the toolchain does. Only a tiny part of the code needs to be
> built for ARMv4, and in general we want to benefit from using ARMv7.

Then you should probably still link against a ARMv4 specific libgcc.

If you were building U-Boot's libgcc code with optimization set for
ARMv7 this would not fix anything.

Best regards,

Wolfgang Denk
Simon Glass - Jan. 5, 2012, 8:42 p.m.
Hi,

On Thu, Jan 5, 2012 at 12:17 PM, Wolfgang Denk <wd@denx.de> wrote:
> Dear Stephen Warren,
>
> In message <4F05FCBD.2040207@nvidia.com> you wrote:
>>
>> > No, this is NOT a solution, it is a workaround for an inappropriate
>> > toolchain.  If you want to build code for an armv4t system, you must
>> > use a tool chain that supports it.
>>
>> But we don't want to generate code for ARMv4 in general, but rather
>
> Then just turn on the ARMv4 specific options (-march=armv4t -mno-thumb
> -mthumb-interwork -mtune=arm920t ???) for the files that need it.
>
> But as soon as any of these files liks code from libgcc you have to
> decide.

Perhaps we could adjust Tegra's config.mk to use ARMv4T when not
building with the private libgcc?

>
>> ARMv7 as the toolchain does. Only a tiny part of the code needs to be
>> built for ARMv4, and in general we want to benefit from using ARMv7.
>
> Then you should probably still link against a ARMv4 specific libgcc.
>
> If you were building U-Boot's libgcc code with optimization set for
> ARMv7 this would not fix anything.
>

It might be possible to specify ARMv4T on the link flags and have it
pick up the v4T library, even if nearly everything else is ARMv7?

Regards,
Simon

> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
> I'd rather be led to hell than managed to heaven.
Stephen Warren - Jan. 5, 2012, 8:53 p.m.
On 01/05/2012 01:42 PM, Simon Glass wrote:
> Hi,
> 
> On Thu, Jan 5, 2012 at 12:17 PM, Wolfgang Denk <wd@denx.de> wrote:
>> Dear Stephen Warren,
>>
>> In message <4F05FCBD.2040207@nvidia.com> you wrote:
>>>
>>>> No, this is NOT a solution, it is a workaround for an inappropriate
>>>> toolchain.  If you want to build code for an armv4t system, you must
>>>> use a tool chain that supports it.
>>>
>>> But we don't want to generate code for ARMv4 in general, but rather
>>
>> Then just turn on the ARMv4 specific options (-march=armv4t -mno-thumb
>> -mthumb-interwork -mtune=arm920t ???) for the files that need it.

That's exactly what we've already done, but that doesn't affect code
that gets pulled in from libgcc, which is what USE_PRIVATE_LIBGCC
affects IIUC.

>> But as soon as any of these files liks code from libgcc you have to
>> decide.
> 
> Perhaps we could adjust Tegra's config.mk to use ARMv4T when not
> building with the private libgcc?

I believe the relevant U-Boot source files are already built for ARMv4T,
it's just libgcc that's the issue.

>>> ARMv7 as the toolchain does. Only a tiny part of the code needs to be
>>> built for ARMv4, and in general we want to benefit from using ARMv7.
>>
>> Then you should probably still link against a ARMv4 specific libgcc.
>>
>> If you were building U-Boot's libgcc code with optimization set for
>> ARMv7 this would not fix anything.
> 
> It might be possible to specify ARMv4T on the link flags and have it
> pick up the v4T library, even if nearly everything else is ARMv7?

I don't think we use any multilib toolchains, so I don't think that's
possible.
Wolfgang Denk - Jan. 5, 2012, 11:20 p.m.
Dear Stephen,

In message <4F060DD1.9050907@nvidia.com> you wrote:
>
> > It might be possible to specify ARMv4T on the link flags and have it
> > pick up the v4T library, even if nearly everything else is ARMv7?
> 
> I don't think we use any multilib toolchains, so I don't think that's
> possible.

I don't even think you need one with multilib support.  You need one
that provides a libgcc for armv4t, that's all.

It is wrong, always and everywhere, NOT to try to fix the problems at
the origin.  If your tool chain does not meet your requirements, then
the first action should always be to get a working tool chain -
ideally by getting the deficiencies of the currnt one fixed, or by
using another one.

Working around such problems may be a short term approach to get
things running quickly.  But it appears that more and more people make
it a habit to do just that, without even trying to get the real
problems fixed upstream.  That's bad, bad, bad.

Best regards,

Wolfgang Denk

Patch

diff --git a/arch/arm/cpu/armv7/tegra2/config.mk b/arch/arm/cpu/armv7/tegra2/config.mk
index 8f9bdc9..2303dba 100644
--- a/arch/arm/cpu/armv7/tegra2/config.mk
+++ b/arch/arm/cpu/armv7/tegra2/config.mk
@@ -29,3 +29,5 @@ 
 ifdef CONFIG_TEGRA2
 CFLAGS_arch/arm/lib/board.o += -march=armv4t
 endif
+
+USE_PRIVATE_LIBGCC = yes