Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C++] RelWithDebInfo builds disable optimizations #35850

Closed
pitrou opened this issue May 31, 2023 · 7 comments · Fixed by #35856
Closed

[C++] RelWithDebInfo builds disable optimizations #35850

pitrou opened this issue May 31, 2023 · 7 comments · Fixed by #35856
Assignees
Milestone

Comments

@pitrou
Copy link
Member

pitrou commented May 31, 2023

Describe the bug, including details regarding any error messages, version, and platform.

RelWithDebInfo builds add -O0 to compiler flags, effectively disabling optimizations.
This seems to be caused by #15022

Component(s)

C++

@pitrou
Copy link
Member Author

pitrou commented May 31, 2023

@felipecrv Would you like to take a look at this quickly?

@pitrou
Copy link
Member Author

pitrou commented May 31, 2023

@raulcd This could be 12.0.1 material if we can integrate a fix quickly.

@pitrou
Copy link
Member Author

pitrou commented May 31, 2023

Also cc @mapleFU

@mapleFU
Copy link
Member

mapleFU commented May 31, 2023

I guess we might force using Release on benchmark, though Release only uses O2...

@pitrou
Copy link
Member Author

pitrou commented May 31, 2023

No, we should fix this bug. RelWithDebInfo should enable the exact same optimizations as Release.

@kou
Copy link
Member

kou commented May 31, 2023

Oh, sorry.

Does this work?

diff --git a/cpp/cmake_modules/SetupCxxFlags.cmake b/cpp/cmake_modules/SetupCxxFlags.cmake
index 827e0fa4e..2daaabb97 100644
--- a/cpp/cmake_modules/SetupCxxFlags.cmake
+++ b/cpp/cmake_modules/SetupCxxFlags.cmake
@@ -642,8 +642,8 @@ if(NOT MSVC)
   string(APPEND CMAKE_CXX_FLAGS_RELEASE "${CXX_RELEASE_FLAGS}")
   string(APPEND CMAKE_C_FLAGS_DEBUG "${DEBUG_FLAGS}")
   string(APPEND CMAKE_CXX_FLAGS_DEBUG "${DEBUG_FLAGS}")
-  string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO "${C_RELEASE_FLAGS} ${DEBUG_FLAGS}")
-  string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CXX_RELEASE_FLAGS} ${DEBUG_FLAGS}")
+  string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO "${DEBUG_FLAGS} ${C_RELEASE_FLAGS}")
+  string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO "${DEBUG_FLAGS} ${CXX_RELEASE_FLAGS}")
 endif()
 
 message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")

@kou
Copy link
Member

kou commented May 31, 2023

I've opened a pull request for easy to try: #35856

pitrou pushed a commit that referenced this issue Jun 1, 2023
### Rationale for this change

We should not disable optimization with RelWithDebInfo. We just add debug information with RelWithDebInfo.

### What changes are included in this PR?

This change prioritizes optimization flags over debug flags.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Yes.
* Closes: #35850

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Antoine Pitrou <antoine@python.org>
@pitrou pitrou added this to the 13.0.0 milestone Jun 1, 2023
@raulcd raulcd modified the milestones: 13.0.0, 12.0.1 Jun 1, 2023
raulcd pushed a commit that referenced this issue Jun 1, 2023
### Rationale for this change

We should not disable optimization with RelWithDebInfo. We just add debug information with RelWithDebInfo.

### What changes are included in this PR?

This change prioritizes optimization flags over debug flags.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Yes.
* Closes: #35850

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Antoine Pitrou <antoine@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants