← Back to team overview

kicad-developers team mailing list archive

Re: gcc 4.7.x and optimization flags

 

On 10/16/2012 01:17 PM, Wayne Stambaugh wrote:
> On 10/16/2012 1:31 AM, Dick Hollenbeck wrote:
>> On 10/15/2012 08:49 PM, Wayne Stambaugh wrote:
>>> Dick,
>>>
>>> I just committed a fix so that the only time -O1 is only used when the
>>> GCC version is >= 4.7.  When you get a chance, please test it out to
>>> make sure it works with GCC versions < 4.7.  Both my Linux and Windows
>>> build environments are using GCC >= 4.7.  I suppose I could install an
>>> older version of GCC on Linux when I get chance.
>>>
>>> Wayne
>>
>> Thanks for doing that.  Someday we might take it even further and compile on those certain
>> needed files under 4.7.x that must be done with -O1, others with -O2.
>>
>> This is easier than it sounds since gcc will ignore all but the right most optimization
>> setting on the command line.
>>
>> So really, you just have to set set_source_file_properties() on a few files and pass in
>> the -O1 as COMPILE_FLAGS or such (don't hold me on spelling), and as long as CMake appends
>> that to other stuff, then -O1 will prevail on only those files.
>
> Sounds reasonable.  It would only apply to the source files that include 
> the Boost polygon library.  JP would have a better idea about which 
> source files would need to be compiled with -O1.  Since my 
> -Wno-narrowing fix also applies to the Boost polygon library we could 
> throw that in there as well.  If JP doesn't have time, I'll take a look 
> at it when I get a chance.
>
> Wayne


>From another project I am using CMake, this might work:


set_source_files_properties( file1.cpp file2.cpp ...
  PROPERTIES
    COMPILE_FLAGS   "-O1"
  )


Wrap that in "if test" condition of "GCC and 4.7"





Follow ups

References