Subject: Re: sparc and gcc4?
To: Christos Zoulas <christos@astron.com>
From: Christian Smith <csmith@thewrongchristian.org.uk>
List: port-sparc
Date: 06/27/2006 17:05:37
Christos Zoulas uttered:

> In article <20060627083854.GA25940@NetBSD.org>,
> Martin Husemann  <martin@NetBSD.org> wrote:
>> On Mon, Jun 26, 2006 at 11:14:50PM +0000, Martin Husemann wrote:
>>> FWIW: a gcc 4 kernel crashes on my LX imediately (alginment fault) when
>>> it is about to mount /.
>>
>> So I found that the kernel works fine when compiled with -O2, but I had
>> a -Os in makeoptions.
>>
>> That made me curious, and experiments show that a kernel compiled with
>> anything != -O2 crashes with alignment faults or illegal instructions.
>>
>> Maybe we should drop back to gcc 3.3.6 for now as default, untill this
>> code gen issues have been resolved?
>
> I think we should publish that if you compile with -Os or -O3 things might
> not work, but please report bugs. We should create a matrix of what works
> at which compilation level.


Well, -Os disables various alignment flags. From man gcc:
        -Os Optimize for size.  -Os enables all -O2 optimizations that do not
            typically increase code size.  It also performs further optimiza-
            tions designed to reduce code size.

            -Os disables the following optimization flags: -falign-functions
            -falign-jumps  -falign-loops -falign-labels  -freorder-blocks
            -freorder-blocks-and-partition -fprefetch-loop-arrays

Probably a bug in the gcc SPARC code as everything should be aligned. Try 
putting in the align optimizations back, compiling with:
   -Os -falign-functions=4 -falign-jumps=4 -falign-loops=4 -falign-labels=4

The -falign flags are probably a hold over from the CISC implementations 
where unaligned accesses are allowed but sub-optimal.


>
> christos
>

Christian

--
     /"\
     \ /    ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
      X                           - AGAINST MS ATTACHMENTS
     / \