Make Whole Program Optimization (WPO) optional on MSVC (backport #532)#535
Open
mergify[bot] wants to merge 1 commit intogz-cmake5from
Open
Make Whole Program Optimization (WPO) optional on MSVC (backport #532)#535mergify[bot] wants to merge 1 commit intogz-cmake5from
mergify[bot] wants to merge 1 commit intogz-cmake5from
Conversation
* Add GZ_MSVC_WPO option to toggle Whole Program Optimization This adds a \GZ_MSVC_WPO\ option (default ON) that controls the injection of \/GL\ and \/LTCG\ on MSVC. It also fixes a bug where \/LTCG\ was only applied to RelWithDebInfo shared linker flags, and not to Release or other target types. \/INCREMENTAL:NO\ is appropriately restricted to RelWithDebInfo. Generated-By: Gemini 3.1 Pro Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai> * Add /bigobj flag to MSVC_MINIMAL_FLAGS Increases the number of sections in an object file to prevent C1128 errors when building complex templated code with Whole Program Optimization (/GL) enabled. Generated-By: Gemini 3.0 Pro --------- Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai> Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org> (cherry picked from commit a3c8e29)
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🦟 Bug fix
Summary
This PR introduces an option to toggle Whole Program Optimization (WPO) on MSVC. On template heavy libraries such as gz-physics, WPO causes a large memory spike causing the system to do a lot of swapping thereby dramatically increasing the build time. The current build time for gz-physics PRs on the
mainbranch is 1h 17m (https://build.osrfoundation.org/job/gz_physics-pr-cnlwin/232/timings/). With WPO disabled, it is reduced to 29m 🎉 (https://build.osrfoundation.org/job/gz_physics-pr-cnlwin/234/timings).This PR also fixes a few other bugs in the way flags are set on
CMAKEvariables:/LTCGlinker flag was only being applied toRelWithDebInfoshared libraries. It is now correctly applied across allReleaseandRelWithDebInfotarget types (executables, shared libraries, and static libraries) when WPO is enabled. This fixes the warnings in most of our windows builds, e.g.:/bigobjto minimal MSVC flags: Included the/bigobjflag inMSVC_MINIMAL_FLAGS. This preventsC1128: number of sections exceeded object file format limiterrors, which I believe now occurs because WPO is properly set on all targets (see https://build.osrfoundation.org/job/gz_sim-pr-cnlwin/668/).Checklist
codecheckpassed (See contributing)Generated-by: Gemini 3.0 Pro
Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-byandGenerated-bymessages.Backports: If this is a backport, please use Rebase and Merge instead.
This is an automatic backport of pull request #532 done by Mergify.