[U-Boot] WARNING: in gcc 4.5.0 and 4.5.1 volatile is ignored

Wolfgang Denk wd at denx.de
Sat Jan 22 15:14:06 CET 2011


Dear Alexander Holler,

In message <4D3AD19B.6030102 at ahsoftware.de> you wrote:
> 
> because I've recently seen some other places where volatile is used to 
> access registers without using read?() or write?() and many people seem 
> to start using 4.5.1, I want to post this warning using a descriptive 
> subject.
> 
> The keyword volatile might not have any effect when reading when gcc 
> 4.5.0 or 4.5.1 is used.

Actuelly this warning should eventually be extended to carefully check
results when using any of the currently available 4.5.x versions of
GCC.

> The appropriate bug seems to be that one:
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45052

This is probably only one part of the problem.  Thereare a number of
other bugs in thes ecompiler versions, for example this one:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44392

Unfortunately there appears to be little interest within the GCC folks
to fix porolems that affect only such lunatic fringe groups as the
embedded folks, so I don't expect to see fixes any time soon.  Even
bigger projects like the Linux Foundation driven Poky (resp. Yocto
project) capitulated and stopped using -Os, see for example here:
http://thread.gmane.org/gmane.linux.embedded.poky/2311/focus=2565

Yes, "-Os" is default setting for U-Boot - changing it to (for example)
-O2 will generate significantly larger code and even break a number of
boards.


It appears there are a number of other issues with GCC 4.5.x that
affect us.  If you are using any such tool chain, and see strange
results or unexpected breakages, it is probably a very good idea to
try another (older, working) tool chain first, before spending any tme
on debugging.


> You might either change such code to use readb(), readw() or readl(), or 
> you have to use either an older version of gcc or a version >= 4.5.2 (it 
> is fixed in 4.5.2).

We will take care to provide working (at least with most of the
compiler versions) I/O accessors (including sufficient memory
barriers), and all code that uses the old volatile pointer approach
to access device registers should be converted to use proper I/O
acessors.

> A patch for write?() and read?() is currently in the 
> u-boot-arm-repository (but not in the master and not in 2010.12):
> 
> http://lists.denx.de/pipermail/u-boot/2011-January/084885.html


Thanks for raising this issue again.

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 at denx.de
The ideal situation is to have massive computing power right at home.
Something that dims the streetlights and shrinks the picture  on  the
neighbours' TVs when you boot it up.


More information about the U-Boot mailing list