I just noticed that some of my libraries are greater when compiled with gcc 4.4.3 instead of gcc 4.3.2. Diffing the output of "gcc --help=optimizers -Q -Os" shows this in 4.3.2:
and this for 4.4.3:
when explicitely disabling the alignment options then the code size shrinks. For libxml2 in my case from 704256 to 675584 bytes.
The manual says:
-Os disables the following optimization flags: -falign-functions
-falign-jumps -falign-loops -falign-labels -freorder-blocks
which is not true (even not for 4.3.2 since loop alignment was enabled). Some other opts like -freorder-blocks is enabled as well.
So is this actually a bug or is the documentation outdated or even both?
Subject: Re: New: -Os creates larger binaries than before in some cases (-falign-... options enabled)
Which target is this for?
Sent from my iPhone
On Apr 22, 2010, at 4:48 PM, "rwahl at gmx dot de" <firstname.lastname@example.org
> I just noticed that some of my libraries are greater when compiled
> with gcc
> 4.4.3 instead of gcc 4.3.2. Diffing the output of "gcc --
> help=optimizers -Q
> -Os" shows this in 4.3.2:
> -falign-jumps [disabled]
> -falign-labels [disabled]
> -falign-loops [enabled]
> and this for 4.4.3:
> -falign-functions [enabled]
> -falign-jumps [enabled]
> -falign-labels [enabled]
> -falign-loops [disabled]
> when explicitely disabling the alignment options then the code size
> For libxml2 in my case from 704256 to 675584 bytes.
> The manual says:
> -Os disables the following optimization flags: -falign-functions
> -falign-jumps -falign-loops -falign-labels -freorder-
> -freorder-blocks-and-partition -fprefetch-loop-arrays
> which is not true (even not for 4.3.2 since loop alignment was
> enabled). Some
> other opts like -freorder-blocks is enabled as well.
> So is this actually a bug or is the documentation outdated or even
> Summary: -Os creates larger binaries than before in some
> cases (-
> falign-... options enabled)
> Product: gcc
> Version: 4.4.3
> Status: UNCONFIRMED
> Severity: normal
> Priority: P3
> Component: middle-end
> AssignedTo: unassigned at gcc dot gnu dot org
> ReportedBy: rwahl at gmx dot de
All my own cross compilers for ARM and x86 hosted on x86 and the native gcc in Fedora 12 (x86) show this behavior.
Created attachment 20535 [details]
Disable alignment when using -Os
The attached patch fixes the problem. It could be written in a more elegant way by changing just opt1_max but this would modify the semantic of this variable and it should be renamed accordingly.
On ARM the fix is probably a NOP because the default alignment seems to be 1 anyway but I haven't checked this.
The output of "gcc -Q --help=optimizers" seems to be broken for the alignment options because on one hand these options are not boolean and on the other hand falign-loops is reported as enabled when it has been disabled and vice versa.