[CMake] Remove force overwrite of compiler optimisation flags.#7932
[CMake] Remove force overwrite of compiler optimisation flags.#7932hageboeck merged 2 commits intoroot-project:masterfrom
Conversation
|
@phsft-bot build just on ROOT-performance-centos8-multicore/default with flags -DCMAKE_CXX_FLAGS_RELEASE=brokenFlag |
|
Starting build on |
|
Above is just a demo. Let's do the real build after we see it fail. |
In CMake, variables like CMAKE_CXX_FLAGS_RELEASE etc should be cache variables, so users can set them from outside. ROOT, however, FORCE overwrote them, so users cannot change anything. Now, the variables are not set by ROOT at all, we use the CMake defaults. It is fine to append or replace substrings, but the variables should NOT be overwritten to give users some options. In case ROOT wants to move away from CMake defaults, it can be done like this: diff --git a/CMakeLists.txt b/CMakeLists.txt index e40b84a..ab41612006 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,11 @@ endforeach() include(cmake/modules/CaptureCommandLine.cmake) +set(CMAKE_CXX_FLAGS_DEBUG_INIT "-O1 -g") +set(CMAKE_CXX_FLAGS_ASSERT_INIT "-O2 -g") + project(ROOT)
4c7c19c to
9901376
Compare
|
Starting build on |
|
Why should it break with the broken flag? We don't build |
|
I didn't think it is RelWithDeb. I pushed too fast, so the build hadn't even started, so we wouldn't know for sure. |
|
@phsft-bot build just on ROOT-fedora30/cxx14 with flags -DCMAKE_CXX_FLAGS_RELEASE=brokenFlag |
|
Starting build on |
|
Build failed on ROOT-fedora30/cxx14. Errors:
|
I guess that settles it @stwunsch. 🙂
|
CMakeLists.txt
Outdated
| string(REGEX REPLACE "-.NDEBUG" "" CMAKE_CXX_FLAGS_${BUILD_TYPE} "${CMAKE_CXX_FLAGS_${BUILD_TYPE}}") | ||
| string(REGEX REPLACE "-.NDEBUG" "" CMAKE_C_FLAGS_${BUILD_TYPE} "${CMAKE_C_FLAGS_${BUILD_TYPE}}") |
There was a problem hiding this comment.
Why can I not -INDEBUG? Why do you break my favorite CXX flag -DNDEBUG_EVERYTHING=42? ;-) What about -DNDEBUG=1?
| string(REGEX REPLACE "-.NDEBUG" "" CMAKE_CXX_FLAGS_${BUILD_TYPE} "${CMAKE_CXX_FLAGS_${BUILD_TYPE}}") | |
| string(REGEX REPLACE "-.NDEBUG" "" CMAKE_C_FLAGS_${BUILD_TYPE} "${CMAKE_C_FLAGS_${BUILD_TYPE}}") | |
| string(REGEX REPLACE "-[DU]NDEBUG(=[^ ]+)? " "" CMAKE_CXX_FLAGS_${BUILD_TYPE} "${CMAKE_CXX_FLAGS_${BUILD_TYPE}}") | |
| string(REGEX REPLACE "-[DU]NDEBUG(=[^ ]+)? " "" CMAKE_C_FLAGS_${BUILD_TYPE} "${CMAKE_C_FLAGS_${BUILD_TYPE}}") |
Maybe better (since CMake 3.6):
| string(REGEX REPLACE "-.NDEBUG" "" CMAKE_CXX_FLAGS_${BUILD_TYPE} "${CMAKE_CXX_FLAGS_${BUILD_TYPE}}") | |
| string(REGEX REPLACE "-.NDEBUG" "" CMAKE_C_FLAGS_${BUILD_TYPE} "${CMAKE_C_FLAGS_${BUILD_TYPE}}") | |
| list(FILTER CMAKE_CXX_FLAGS_${BUILD_TYPE} EXCLUDE REGEX "-[UD]NDEBUG(=.*)?") | |
| list(FILTER CMAKE_C_FLAGS_${BUILD_TYPE} EXCLUDE REGEX "-[UD]NDEBUG(=.*)?") |
There was a problem hiding this comment.
Ah, true. I didn't know that people could have those as their favourite flags.
My preferred solution is to use
cmake -DCMAKE_CXX_FLAGS_RELEASE=-O3 <src> - less CMake code on our side.
If -Dasserts=On is desired, though, we can extend that regex.
There was a problem hiding this comment.
These are not lists, so have to go for the other solution.
|
Starting build on |
oshadura
left a comment
There was a problem hiding this comment.
I am super supporting the idea to roll back to CMake defaults !!! Let's cross our fingers that testing whole ROOT test suites will work...I just have a question, why we couldn't do this before (e.g. what was fa reason to use specific hardcodeded flags)?
To be honest: |
|
@hageboeck @stwunsch I will vote then to try it in the master and in case of something I can try to setup flags as you told: before project(ROOT) using CMAKE_CXX_*_INIT vars... |
Just note that before |
|
Build failed on ROOT-debian10-i386/cxx14. Errors:
|
|
Build failed on ROOT-fedora31/noimt. Failing tests:
|
|
Build failed on ROOT-performance-centos8-multicore/default. Failing tests: |
|
Build failed on mac1014/python3. Failing tests: |
|
Build failed on ROOT-ubuntu16/nortcxxmod. Failing tests: |
|
Build failed on ROOT-fedora30/cxx14. Failing tests:
|
|
Build failed on mac11.0/cxx17. Failing tests:
|
|
Looks like all these tests are failed because of timeout? |
|
That's likely significant i.e. this PR might introduce wrong flags! Please check the actual compiler invocation ( @hageboeck I suppose). |
|
I had a look. The CI seems to set |
|
I suspect that it's in Axel's list filtering. Will check locally with some printouts. |
|
... confirmed. Will fix. |
|
Explanation: |
Co-authored-by: Axel Naumann <[email protected]>
467ebed to
5166e33
Compare
|
Starting build on |
|
@Axel-Naumann I reverted most of your suggestions, but the regex is still your updated one. I expect the CI to go as desired now. See what ROOT prints for Interesting side note: |
|
@Axel-Naumann about the note, interesting, but it looks like :) |
oshadura
left a comment
There was a problem hiding this comment.
As I already told you, let's try: LGTM! and thanks a lot for finding such a nice solution!
In CMake, variables like CMAKE_CXX_FLAGS_RELEASE etc should be cache
variables, so users can set them from outside. ROOT, however, FORCE
overwrote them, so users cannot change anything.
Now, the variables are not set by ROOT at all, we use the CMake
defaults.
It is fine to append or replace substrings, but the variables should NOT
be overwritten to give users some options.
In case ROOT wants to move away from CMake defaults, it can be done like
this:
Fix #6577