-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Start using optimization (-O0/-O2/-O3/-Os) and debug (-g) flags from CMAKE_CXX_FLAGS_${CFLAGS_BUILD_TYPE} #33388
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
Start using optimization (-O0/-O2/-O3/-Os) and debug (-g) flags from CMAKE_CXX_FLAGS_${CFLAGS_BUILD_TYPE} #33388
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely a pretty big improvement.
I want to point out that this changes one of the optimization levels. The CMake defaults are:
While currently Swift forces -O2 on Release. So this will be a change to -O3 here. |
…CMAKE_CXX_FLAGS_${CFLAGS_BUILD_TYPE}
d515898
to
7ccbc75
Compare
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test macOS platform |
1 similar comment
@swift-ci please test macOS platform |
@gottesmm @airspeedswift @aschwaighofer Any more feedback here? Any concerns about the switch to -O3 for Release (not for RelWithDebInfo though)? |
We really need to do a benchmark run and see the impact on that. |
Isn't What are the code size impacts of using I seemed to remember the loop vectorizer for example inserts speculative code aggressively in the highest opt mode. |
Okay, so it sounds like there are concerns. @compnerd how about I do something like:
to turn this PR into a NFC, and we can discuss separately whether we should switch to the CMake's default? |
Ok, this is now a NFC change only. |
@swift-ci please test |
1 similar comment
@swift-ci please test |
@swift-ci please test Windows platform |
1 similar comment
@swift-ci please test Windows platform |
Hm, the Windows bot failure looks like a real regression: https://ci-external.swift.org/job/swift-PR-windows/6268/console. @compnerd any ideas what's causing it? |
@swift-ci please test Windows platform |
@swift-ci please test Windows platform |
@swift-ci please test |
Build failed |
Build failed |
CMakeLists.txt
Outdated
@@ -629,6 +629,19 @@ if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQU | |||
set(SWIFT_COMPILER_IS_MSVC_LIKE TRUE) | |||
endif() | |||
|
|||
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE) | |||
# Avoid CMake's default -O3 for Release builds. | |||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't set -DNDEBUG
, that overrides the behaviour of LLVM_ENABLE_ASSERTIONS
. I usually build with assertions intentionally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the default in CMAKE_CXX_FLAGS_RELEASE, though. I though it would be better to keep it that way, because we're explicitly checking LLVM_ENABLE_ASSERTIONS and passing -UNDEBUG
or -DNDEBUG
after we include CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}.
@swift-ci please test |
Build failed |
Build failed |
@kubamracek leaving swift at -O2 is the correct thing to do here! Thanks for keeping it like that! |
Set those at the value pre swiftlang#33388 -- this would avoid regressions of disk space usage (in particular around building Swift LTO) Addresses rdar://68091272
Set those at the value pre #33388 -- this would avoid regressions of disk space usage (in particular around building Swift LTO) Addresses rdar://68091272
…gs from CMAKE_CXX_FLAGS_${CFLAGS_BUILD_TYPE} (swiftlang#33388)" This reverts commit 28a2826.
No description provided.