lkml.org 
[lkml]   [2016]   [Jan]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Thoughts about introducing OPTIMIZATION_CFLAG
> As said... I checked only for x86 and acpi only.
>
> For example '-Os' is hardcoded in...
>
> arch/x86/Makefile
> arch/x86/purgatory/Makefile
>
> drivers/acpi/Makefile
> drivers/acpi/acpica/Makefile
>
> For acpi part we have currently both used '-O2' and '-Os' ('-Oz' for
> llvmlinux) in approx 200 make-lines.

Certain parts of the kernel are built in particular ways for specific
reasons where the tradeoffs vary, or where people happen to know that -Os
is the best choice with gcc. Of course those may not be the same trade
offs for llvm.

>
> $ grep '\-O2' build-log_4.4.0-rc8-2-llvmlinux-amd64.txt | grep acpi | wc -l
> 226
> $ grep '\-Oz' build-log_4.4.0-rc8-2-llvmlinux-amd64.txt | grep acpi |
> grep '\-O2' | wc -l
> 200
>
> So, which optimization-cflags is now used if I have both in one
> make-line (and how can I check this)?

Consult the documentation for your compiler. GCC has an 810 page manual
that answers your question quite specifically

"If you use multiple -O options with or without level numbers, the last
such option is the one that is effective"


Don't assume they are contradictory options either. If you have other
optimnisations directly set then if those are after it they will take
effect

eg -Os -fprefetch-loop-arrays

is quite valid.

The GCC manual lists each optimisation it supports and documents exactly
which ones are enabled for each option. From that you should be able to
match them up with llvm.

> How can I switch a optimization-cflags for certain code-parts in the
> Linux-kernel (with or without the kbuild-system)?
> ( So the default optimization-cflags is '-O2' whereas parts wants '-Os'. )

Not sure I follow - that's exactly what the current Makefiles are doing.

> What to do when using CONFIG_CC_OPTIMIZE_FOR_SIZE=y which sets '-Os' explicitly?

That's something you'd need to work out as you regression test and profile
the codebase. A first guess would be to echo what gcc does but deal with
the unfortunate option difference between llvm and gcc.

It may also depend what "optimising for size" means to llvm. Some
compilers take it as a hint to favour smaller but still fast code, others
take it as an instruction to generate very tight but way slower code.
That will change which bits need which options.

Alan




\
 
 \ /
  Last update: 2016-01-04 13:21    [W:0.053 / U:0.824 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site