Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1300658

Re: Thoughts about introducing OPTIMIZATION_CFLAG

From Sedat Dilek <sedat.dilek@gmail.com>
Newsgroups linux.kernel
Subject Re: Thoughts about introducing OPTIMIZATION_CFLAG
Date 2016-01-04 12:50 +0100
Message-ID <qNbOa-2VD-1@gated-at.bofh.it> (permalink)
References <qNb1M-2kn-11@gated-at.bofh.it> <qNbEu-2Rt-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Jan 4, 2016 at 12:33 PM, One Thousand Gnomes
<gnomes@lxorguk.ukuu.org.uk> wrote:
>> 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.
>

Thanks for your reply.

But I think you did not get my problem - to have two different
optimization-levels for a compiler in *one* make-line makes no sense
to me.

So, the kbuild-system adds optimization compiler-flags automatically -
see the upper/root Makefile.
Sort of "inheritance".

My question is how to set *one* optimization-level for whatever
compiler I use to build my Linux-kernel source.

-O1 || -O2 || -O3 || -O4 || -Os ('1..4' and 's' are so-called "optlevels")

It's still not clear if my problem is a compiler bug or not (see [1]
for the details).

Now a bit clearer?

- Sedat -

[1] http://marc.info/?t=144179442100006&r=1&w=1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Thoughts about introducing OPTIMIZATION_CFLAG Sedat Dilek <sedat.dilek@gmail.com> - 2016-01-04 12:00 +0100
  Re: Thoughts about introducing OPTIMIZATION_CFLAG Sedat Dilek <sedat.dilek@gmail.com> - 2016-01-04 12:30 +0100
  Re: Thoughts about introducing OPTIMIZATION_CFLAG One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> - 2016-01-04 12:40 +0100
    Re: Thoughts about introducing OPTIMIZATION_CFLAG Sedat Dilek <sedat.dilek@gmail.com> - 2016-01-04 12:50 +0100
      Re: Thoughts about introducing OPTIMIZATION_CFLAG Michal Marek <mmarek@suse.cz> - 2016-01-04 23:40 +0100
        Re: Thoughts about introducing OPTIMIZATION_CFLAG Sedat Dilek <sedat.dilek@gmail.com> - 2016-01-08 11:10 +0100
          Re: Thoughts about introducing OPTIMIZATION_CFLAG Michal Marek <mmarek@suse.cz> - 2016-01-08 12:40 +0100
            Re: Thoughts about introducing OPTIMIZATION_CFLAG Sedat Dilek <sedat.dilek@gmail.com> - 2016-01-08 12:50 +0100
              Re: Thoughts about introducing OPTIMIZATION_CFLAG Michal Marek <mmarek@suse.cz> - 2016-01-08 13:40 +0100
                Re: Thoughts about introducing OPTIMIZATION_CFLAG Sedat Dilek <sedat.dilek@gmail.com> - 2016-01-08 14:30 +0100

csiph-web