-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
VC++ compiler optimization switches #53849
Comments
Tagging subscribers to this area: @hoyosjs Issue Details
I have some questions:
@dotnet/runtime-infrastructure
|
It has been like that since we have open sourced: https://github.com/dotnet/coreclr/commits/release/2.1/src/pal/tools/windows-compiler-override.txt . I do not think we have history for this file prior to open sourcing. The config for release is configuration is the only sensitive one, changing that would require performance testing. Feel free to clean up and unify the rest. You may want to check impact of the checked build optimization settings on build performance. It is possible that You can also change https://github.com/dotnet/runtime/blob/main/src/libraries/Native/Windows/CMakeLists.txt to include the central optimization settings file while you are on it. |
cc @AndyAyersMS |
Well, it's messier than this. If I force a compiler error in a win-x64 release build, I see a command line with these optimization switches (this is a subset of the compiler switches):
So we throw both It looks like cmake does this. In artifacts\obj\coreclr\windows.x64.Release\CMakeCache.txt, I see:
Maybe we should clear out the cmake default values of this (and the other defaults:
) to give us full control (and avoid ambiguity and warnings/errors from overriding switches). |
As @jkotas said, that was the way it was set before we started the opensourcing of .NET. I am not sure if moving Checked to
It is one of the standard CMake configurations (Debug, Release, RelWithDebInfo and MinSizeRel). We don't actively use it. |
CMake has default settings of options for each compiler / build configuration. It contains these. I think it is a result of the change that @jkoritzinsky made in dotnet/coreclr#23897. We used to use CMAKE_USER_MAKE_RULES_OVERRIDE cmake variable to override the options, which is the way that was designed for that - CMake pulls in the file with overrides to cmake settings like the compiler options after it sets the defaults, but before the options are ever used. With the change, we've stopped using that mechanism and we have probably not realized that we somehow keep having the defaults, at least at some places. However, MSVC doc says:
See https://docs.microsoft.com/en-us/cpp/build/reference/compiling-a-c-cpp-program?view=msvc-160 |
For VC, /O1 is "optimize for size" and /O2 is "optimize for speed". I'd be surprised if the debugging experience was significantly different.
I use Checked for almost everything (until I need to debug something), but I'd like it to be as fast as possible; I don't care about size.
I see we have |
When I switch "Checked" from
The build is bigger: artifacts\bin\coreclr\windows.x64.Checked goes from 85,389,191 to 92,615,635 (presumably more aggressive inlining). E.g.,:
|
Hmm, so I wonder why debugging release / checked build is that much different experience. I have always believed that the optimization level is the reason for that. |
It's possible that additional inlining makes debugging worse. However, my guess is that all the DEBUG code and contracts inhibits optimization, leading to slightly better debugging experience in Checked. |
I created a test PR to switch coreclr Windows Checked builds from |
Windows non-x86 Checked builds have been switched to -O2. Windows x86 is blocked with this issue: #59845. Windows Release builds should also be switched from -Ox to -O2. |
eng\native\configureoptimization.cmake
contains:I have some questions:
/O2
for all non-Debug builds?RelWithDebInfo
actually used? For what?@dotnet/runtime-infrastructure
The text was updated successfully, but these errors were encountered: