Re: Thoughts about introducing OPTIMIZATION_CFLAG

From: Sedat Dilek
Date: Fri Jan 08 2016 - 06:49:11 EST


On Fri, Jan 8, 2016 at 12:31 PM, Michal Marek <mmarek@xxxxxxx> wrote:
> On 2016-01-08 11:03, Sedat Dilek wrote:
>> On Mon, Jan 4, 2016 at 11:37 PM, Michal Marek <mmarek@xxxxxxx> wrote:
>>> Dne 4.1.2016 v 12:47 Sedat Dilek napsal(a):
>>>> 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.
>>>
>>> That we sometimes have -O2 ... -Os on the command line is not a problem,
>>> since any same unix tool parses its options so that the last one of
>>> mutually exclusive options wins.
>>
>> That is new to me and I haven't tested this by dropping arguments in
>> my make-line(s).
>>
>> From where do have this information - sort of "business-life-experience" :-)?
>> Is that documented somewhere in the Linux-sources?
>
> You override a previously set option by appending one with different value:
>
> $ yes | head -n 10 -n 999 -n 2
> y
> y
> $
>
> This pattern is used all over in Makefiles.
>
>
>> Do you agree that it is confusing to have two optlevel arguments in
>> one make-line?
>
> It probably is, but fixing this problem would make the Makefiles unreadable.
>
>
>> Linus suggested me to use a wrapper-script in case of using two
>> different compiler and passing arguments...
>>
>> [ /usr/bin/mycompiler ]
>> #!/bin/bash
>>
>> gcc-4.9 "$@"
>> - EOF -
>>
>> According to your statement passing an optlevel here in this script
>> will never-ever be recognized - as it is at the begin-of-(make)-line.
>
> Pass it as the last argument.
>

How do I do that?

- Sedat -

>
>> So how should someone change the Linux-sources to test a different
>> optlevel than -O2?
>
> make KCFLAGS=-O3
>
> However, per-directory and per-file cflags set in Makefiles will take
> precedence. If you want to override these as well, use the wrapper.
>
> Michal