Skip to contentSkip to conversation

add a config option for -Os compilation

PATCH Andi Kleen 4 participants 4 messages Oct 18, 2003 – Oct 19, 2003 9 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 649730000.1066491920@[10.10.2.4].suse.lists.linux.kernel

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Andi Kleen

author
#9 lore raw
Quoted 3 lines · Andrew Morton

And bear in mind that you can see significant changes in benchmark results between equivalent kernels even when the optimisation level is kept the same, due to aliasing and alignment luck.

It also depends on a lot on the compiler version. On 2.95 it was common wisdom that -Os is often fastest, but that changed in later versions.

Best would be actually a mix of both - setting it case by case. That's already done in specific cases, e.g. ACPI is always compiled with -Os. This could be done for other files which are clearly slow path too.

Profile feedback is unfortunately not an option because it is too unpredictable and causes maintenance problems.

-Andi

#10 lore raw

Hi all,

Quoted 4 lines · Andi Kleen

Best would be actually a mix of both - setting it case by case. That's already done in specific cases, e.g. ACPI is always compiled with -Os. This could be done for other files which are clearly slow path too.

If there is is guarantee fro the GCC Steering Comitee, that there will never be any ABI changes generated from the differences there (like structure padding on/off).

Maybe there should be sth. in the build system for that, which is called $(call optimize_for_speed, $target) and $(call optimize_for_size,$target) which then can be added on a per file basis and per directory tree, where it really matters and letting it to the default otherwise.

That way we can tune gradually and remove GCC options.

Simple implementation today:

optimize_for_speed := CFLAGS_$1 += -O3
optimize_for_size := CFLAGS_$1 += -Os

Sam: What do you think?

Regards

Ingo Oeser

#11 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 1 line · Ingo Oeser

Hi all,

Hi Ingo

Quoted 4 lines

Simple implementation today:

optimize_for_speed := CFLAGS_$1 += -O3
optimize_for_size := CFLAGS_$1 += -Os

I experienced many problems while using -O3, because it may randomly inline functions, that are not marked inline. For example -O3 made ide-scsi on 2.4 nonworking for me.
The book "Linux Device Drivers" has a longer explanation for _not_ using -O3 on kernels.

Quoted 4 lines

Regards

Ingo Oeser

- --
Regards Michael Buesch [ http://www.tuxsoft.de.vu ] -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/kpsfoxoigfggmSgRAgKEAJ9VwoVGyaP3qIm+RT0o3Q9pAhxMYgCeMz9f vLJH6H+xM1yXfKXaXg2IPF8=
=oQIW
-----END PGP SIGNATURE-----

#12 lore raw
In reply to Ingo Oeser
Quoted 7 lines · Ingo Oeser

Maybe there should be sth. in the build system for that, which is called $(call optimize_for_speed, $target) and $(call optimize_for_size,$target) which then can be added on a per file basis and per directory tree, where it really matters and letting it to the default otherwise.

That way we can tune gradually and remove GCC options.

Quoted 7 lines

Simple implementation today:

optimize_for_speed := CFLAGS_$1 += -O3
optimize_for_size := CFLAGS_$1 += -Os

Sam: What do you think?

Focussing on -O2 versus -Os is too narrowscoped for the build system. A much more general solution is needed, without loosing the flexibility we have today.
For 2.7 I have planned making it possible to modify CFLAGS, and make the change be effective for all recursive builds.
This could be usefull if for example acpi decides to use -Werror for all files. One change in one makefile and the desired effect is achieved. The same infrastructure will be possible to use for -Owhatever.

We sould stick with -O2 for 2.6, lets play with other settings for 2.7. Router people and others with special needs can finetune it at will in 2.6 - it is one line in the top-level makefile so not a big deal.

Sam