[openib-general] respect CFLAGS in OSM

Pete Wyckoff pw at osc.edu
Mon Jan 23 08:07:19 PST 2006


eitan at mellanox.co.il wrote on Mon, 23 Jan 2006 15:27 +0200:
> I have looked again at this patch and what it is changing. 
> My understanding is that you found the -g -O2 CLFAGS (provided through
> the specific target CFLAGS) unneeded. You also think they will interfere
> with settings you might want to provide from the command line. 
> 
> I have just double checked what I new to be the rule for autoconf:
> If the user provides CFLAGS or LDFLAGS from the command like - they are
> appended to the compile or link flags. The impact on gcc is that the
> later settings - i.e. those provided by the user take precedence over
> the flags provided at the beginning of the command line. So the patch
> below is actually not needed. 
> 
> Just to convince you I attach some gcc traces showing that -O0 -O2 acts
> like -O2 and 
> -O2 -O0 acts like -O0.
> 
> Bottom line I would like to keep the code as it is without any change
> such that default installation will use the -O2 mode.

Yes, later "-O" options do override previous ones.  I didn't think
of explicitly disabling optimization with -O0 in my build script.
The implication is that you want me to do the following to compile a
debugging version of osm:

    CFLAGS="-g -O0" ./configure ...

rather than what I expected to work:

    CFLAGS="-g" ./configure ...

I can deal with that, and it's not a big enough concern to me now
that you've pointed out this work-around.  Feel free to ignore my
suggestion, then: it's your code.

My surprise comes from having become accustomed to autoconf-based
programs that always use the user-specified CFLAGS exactly if
given.  AC_PROG_CC sets it to "-g -O2" by default for gcc only if no
CFLAGS was set by the user.  If I don't want -g or don't want -O2,
usually it is easy to make that happen without editing files.

		-- Pete



More information about the general mailing list