View Issue Details

IDProjectCategoryView StatusLast Update
0027417CommunityOCCT:Configurationpublic2020-07-21 12:43
ReporterBenjaminBihler Assigned Tobugmaster  
PrioritynormalSeveritytweak 
Status closedResolutionfixed 
PlatformMinGW-w64OSWindows 
Target Version7.1.0Fixed in Version7.1.0 
Summary0027417: Choose a Better Default Release Optimization Parameter for MinGW-w64
DescriptionIn my opinion CMake is doing a bad job by proposing "-O3" as the default release optimization parameter for MinGW-w64. In my tests, the binaries become larger, but the speed is almost the same. (I have not done comparisons on Linux, there "-O3" might indeed be better than "-O2".) Also other build tools like qmake set the default optimization parameter to "-O2".

I would therefore propose to set the default release optimization parameter to "-O2", if the compiler is MinGW. Actually this parameter can easily be overwritten by the user, but this would mean proposing the optimization parameter that has been proven to be best at least in some cases.
Steps To ReproduceNot necessary
TagsNo tags attached.
Test case number

Relationships

related to 0027319 assigned Open CASCADE Configuration, Cmake - cmake's c/cxx corresponding flags are not updated in cmake gui after changes in cmake script 
parent of 0031677 closedbugmaster Community Configuration - Allow Optimization Level O3 When Compiling With G++ 

Activities

git

2016-04-22 13:09

administrator   ~0053499

Branch CR27417 has been created by BenjaminBihler.

SHA-1: 1524979ab2d2dcb093bbe2765c09fab0a3d1e5f5


Detailed log of new commits:

Author: Benjamin Bihler
Date: Fri Apr 22 12:07:52 2016 +0200

    0027417: Coose a Better Default Release Optimization Parameter for MinGW-w64
    
    Forcing CMAKE_CXX_FLAGS_RELEASE to -O2 -DNDEBUG, if the compiler is MinGW-w64.

ibs

2016-04-25 11:14

developer   ~0053534

Dear Benjamin,

It will be great if you replace "-O3" with "-O2" in such way, for example:

string (REGEX MATCH "-03" IS_O3_CXX "${CMAKE_CXX_FLAGS_RELEASE}")
if (IS_O3_CXX)
  string (REGEX REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
else()
  set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
endif()

2. "FORCE" is not necessary for only one flag due to 0027319 issue will cover this omission.

BenjaminBihler

2016-04-25 11:46

developer   ~0053537

Dear ibs,

thank you for the hint. Your solution looks nicer, I have done it the other way, since the variabled seemed not to be updated.

Still your code does not work here. I have added debug output, which leads to the following lines:

# Set default release optimization option to O2 instead of O3, since in
  # some OCCT related examples, this gives significantly smaller binaries
  # at comparable performace with MinGW-w64.
  message ("Old CMAKE_CXX_FLAGS_RELEASE variable: ${CMAKE_CXX_FLAGS_RELEASE}")
  string (REGEX MATCH "-03" IS_O3_CXX "${CMAKE_CXX_FLAGS_RELEASE}")
  message ("IS_O3_CXX: ${IS_O3_CXX}")
  if (IS_O3_CXX)
    message("Found -O3 string")
    string (REGEX REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
    message ("New variable: ${CMAKE_CXX_FLAGS_RELEASE}")
  else()
    message ("Did not find -O3 string")
    set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
  endif()




The output is

Old CMAKE_CXX_FLAGS_RELEASE variable: -O3 -DNDEBUG
IS_O3_CXX:
Did not find -O3 string

which shows that something did not work correctly, but I could not figure out what it is. Can you?


Thanks,
Benjamin

ibs

2016-04-25 11:56

developer   ~0053542

Benjamin,

there is a doubt that ' string (REGEX MATCH "-03" IS_O3_CXX "${CMAKE_CXX_FLAGS_RELEASE}") ' contains "zero" but "O" letter. It's my fault due to the previous my example was a speculative. Could you replace "-03" with "-O3" and check again?

git

2016-04-25 12:04

administrator   ~0053544

Branch CR27417 has been updated by BenjaminBihler.

SHA-1: 06d29f0f8160766bccb9c5977ca0aa6b87f782c1


Detailed log of new commits:

Author: Benjamin Bihler
Date: Mon Apr 25 11:04:13 2016 +0200

    0027417: Choose a Better Default Release Optimization Parameter for MinGW-w64
    
    Switched to replacing optimization parameter instead of overwriting
    CMAKE_CXX_FLAGS_RELEASE string

BenjaminBihler

2016-04-25 12:05

developer   ~0053545

Now it works! My editor here displays absolutely no difference between O and zero. ;-)

ibs

2016-04-25 12:09

developer   ~0053546

Great! :) grateful to you for the participation :)

ibs

2016-04-25 12:09

developer   ~0053547

dear bugmaster, please integrate the fix

git

2016-05-20 12:22

administrator   ~0054204

Branch CR27417 has been deleted by inv.

SHA-1: 06d29f0f8160766bccb9c5977ca0aa6b87f782c1

Related Changesets

occt: master a139a353

2016-04-22 10:07:52

BenjaminBihler


Committer: bugmaster Details Diff
0027417: Coose a Better Default Release Optimization Parameter for MinGW-w64

Forcing CMAKE_CXX_FLAGS_RELEASE to -O2 -DNDEBUG, if the compiler is MinGW-w64.

Switched to replacing optimization parameter instead of overwriting
CMAKE_CXX_FLAGS_RELEASE string
Affected Issues
0027417
mod - adm/cmake/occt_defs_flags.cmake Diff File

Issue History

Date Modified Username Field Change
2016-04-22 13:05 BenjaminBihler New Issue
2016-04-22 13:05 BenjaminBihler Assigned To => BenjaminBihler
2016-04-22 13:09 git Note Added: 0053499
2016-04-22 13:11 BenjaminBihler Assigned To BenjaminBihler => bugmaster
2016-04-22 13:11 BenjaminBihler Status new => resolved
2016-04-22 13:11 BenjaminBihler Steps to Reproduce Updated
2016-04-22 13:16 abv Assigned To bugmaster => ibs
2016-04-25 11:14 ibs Note Added: 0053534
2016-04-25 11:14 ibs Assigned To ibs => BenjaminBihler
2016-04-25 11:14 ibs Status resolved => feedback
2016-04-25 11:14 ibs Relationship added related to 0027319
2016-04-25 11:46 BenjaminBihler Note Added: 0053537
2016-04-25 11:56 ibs Note Added: 0053542
2016-04-25 12:04 git Note Added: 0053544
2016-04-25 12:05 BenjaminBihler Note Added: 0053545
2016-04-25 12:09 ibs Note Added: 0053546
2016-04-25 12:09 ibs Note Added: 0053547
2016-04-25 12:09 ibs Assigned To BenjaminBihler => bugmaster
2016-04-25 12:09 ibs Status feedback => reviewed
2016-04-29 16:10 bugmaster Changeset attached => occt master a139a353
2016-04-29 16:10 bugmaster Status reviewed => verified
2016-04-29 16:10 bugmaster Resolution open => fixed
2016-05-20 12:22 git Note Added: 0054204
2016-12-09 16:31 aiv Status verified => closed
2016-12-09 16:37 aiv Fixed in Version => 7.1.0
2020-07-21 12:43 kgv Relationship added parent of 0031677