G ++ includes invalid flags on -O

I'm currently doing some experimentation with GNU C ++ - the compiler and the -Os optimization option for minimal code size. I checked the flags of the included compiler on -Os with the following command:

g++ -c -Q -Os --help=optimizers | grep "enabled" 


I got a list of allowed options:

 -faggressive-loop-optimizations [enabled] -falign-functions [enabled] -falign-jumps [enabled] -falign-labels [enabled] -falign-loops [enabled] -fasynchronous-unwind-tables [enabled] ... 


This seems a little strange, because I also looked at which flags should be enabled on -O, here , and in the -Os section it says that all falign- parameters should be disabled to minimize code.


Q:. So is this a mistake or am I doing something wrong here? The reason is after reading that the flags are falign- I really think they should be disabled in -O!



My gcc version is 4.9.2 and I am working on Arch-Linux.

Thanks already for the help :)

+6
source share
1 answer

Q: So is this a mistake, or am I doing something wrong? Because after reading the flag flags, I really think they should be disabled in -O

I think Hans did a good job of finding part of the problem. This is definitely a documentation error. But none of the GCC commented on why -Os turned them on, so you may not have all the information.

Older ARM devices were very intolerant of unrelated access. Devices with older levers included ARMv4, and I think ARMv5. If you performed unrelated access, you will receive SIGBUS (there, done, received a T-shirt).

Modern ARM devices capture unmanaged calls such as x86 processors, so you no longer get SIGBUS . Instead, you simply accept a performance penalty.

You should try to specify the architecture if these parameters are an artifact from older ARM device support. For example, -march=armv7 . If you find it on ARMv6 and ARMv7, this might still be a mistake. It depends on what the GCC team decided that the compromise was sufficient for ARM (code size and performance penalty).

+2
source

Source: https://habr.com/ru/post/979982/


All Articles