[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160104113318.700a9ed0@lxorguk.ukuu.org.uk>
Date: Mon, 4 Jan 2016 11:33:18 +0000
From: One Thousand Gnomes <gnomes@...rguk.ukuu.org.uk>
To: Sedat Dilek <sedat.dilek@...il.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Michal Marek <mmarek@...e.cz>, Sam Ravnborg <sam@...nborg.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
Arnd Bergmann <arnd@...db.de>, Ingo Molnar <mingo@...hat.com>,
linux-kbuild@...r.kernel.org,
Linux ACPI <linux-acpi@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
"the arch/x86 maintainers" <x86@...nel.org>
Subject: Re: 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists