Repository navigation
Conversation
blowekamp
force-pushed
the
enh/interprocedural-optimization
branch
from
October 22, 2026 18:13
e4b2010 to
27d129b
Compare
Add an option, default OFF, to enable interprocedural optimization (LTO) for Release, RelWithDebInfo and MinSizeRel builds. Support is verified with check_ipo_supported. The CMAKE_INTERPROCEDURAL_OPTIMIZATION_<CONFIG> variables are set before ITK is added so FetchContent builds of ITK use them, and they are forwarded to the ITK, Elastix and SimpleITK projects in the SuperBuild. Standalone language wrapping projects include the same module so they link against an IPO build of SimpleITK with IPO enabled. Co-authored-by: Copilot <[email protected]>
blowekamp
force-pushed
the
enh/interprocedural-optimization
branch
from
October 27, 2026 13:24
27d129b to
c567f28
Compare
blowekamp
marked this pull request as ready for review
October 27, 2026 14:10
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Disabling IPO after an enabled SuperBuild leaves cached IPO settings active in existing child builds.
1 open issue
What changed in this PR
Adds opt-in interprocedural optimization (LTO) to SimpleITK’s build system, including dependency builds and standalone language wrappers.
Changes:
- Checks compiler IPO support and enables it for optimized build configurations.
- Propagates IPO settings through FetchContent and SuperBuild.
- Exercises IPO in one macOS ARM64 CI entry with serialized linking and documents usage.
| File | Description |
|---|---|
SuperBuild/SuperBuild.cmake |
Loads the IPO module and forwards settings to child projects. |
docs/source/building.rst |
Documents the option, build costs, and standalone wrapper usage. |
CMakeLists.txt |
Initializes IPO before adding ITK. |
CMake/sitkProjectLanguageCommon.cmake |
Adds IPO support to standalone language wrappers. |
CMake/sitkInterproceduralOptimization.cmake |
Defines the option, checks support, and enables optimized configurations. |
.github/workflows/Build.yml |
Enables IPO and serialized linking in one CI entry. |
.github/workflows/additional_dictionary.txt |
Adds “interprocedural” to the spelling dictionary. |
Review effort: Balanced
dave3d
approved these changes
Oct 27, 2026
blowekamp
force-pushed
the
enh/interprocedural-optimization
branch
2 times, most recently
from
October 27, 2026 14:51
1128dc4 to
c567f28
Compare
Only one entry uses IPO to limit CI time, since IPO builds took 2-3 extra hours on hosted and Linux runners. This entry runs on a self-hosted runner, so links are not serialized. Co-authored-by: Copilot <[email protected]>
blowekamp
force-pushed
the
enh/interprocedural-optimization
branch
from
October 27, 2026 19:41
c567f28 to
4cbca79
Compare
Member
Author
|
The IPO linking is not working out of the box with the self hosted runner with generous resources. This option can be directly enable through the CMAKE_INTERPROCEDURAL_OPTIMIZATION_{config} variables. This does not need a special SimpleITK option. |
3 tasks done
blowekamp
added a commit
that referenced
this pull request
Nov 4, 2026
Add CMAKE_INTERPROCEDURAL_OPTIMIZATION and the per-configuration CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE/RELWITHDEBINFO/MINSIZEREL variables to ep_common_list so that IPO/LTO settings passed to the top-level SuperBuild configure are forwarded to the ITK, Elastix, SimpleITKExamples, Lua, and SimpleITK sub-builds. Previously these cache variables were not propagated at all, so e.g. -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON set on the SuperBuild configure silently had no effect on the sub-projects. Debug is intentionally excluded, since IPO is not meaningful for debug builds. This is a narrower follow-up to the discussion in #2766, which proposed a full SimpleITK_INTERPROCEDURAL_OPTIMIZATION option but was closed due to CI cost; this change only wires up propagation of the variables CMake itself already recognizes, without adding any new option or CI behavior.
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.

Add a
SimpleITK_INTERPROCEDURAL_OPTIMIZATIONCMake option (default OFF) that enables LTO for Release, RelWithDebInfo and MinSizeRel builds. It applies to ITK in both the FetchContent and SuperBuild paths.The second commit enables the option in a single CI entry (
mac-arm64-elastix-python) so it is exercised in CI. That entry runs on a self-hosted runner, so links are not serialized.Design
check_ipo_supported()(C and CXX) is run when the option is ON; configuration fails if IPO is not supported.CMAKE_INTERPROCEDURAL_OPTIMIZATION_<CONFIG>is set before ITK is added so FetchContent ITK inherits it.Local measurements (AppleClang 21, arm64, static, Release, no Elastix)
HelloWorldRuntime: about 22% faster affine MeanSquares registration and 7-8% faster small-image filter calls. Large-image filters were unchanged.
Testing
Configure-only checks of the FetchContent and SuperBuild paths:
-flto=thinis present for ITK and SimpleITK objects when ON, absent when OFF, and the IPO variables reach the ITK and SimpleITK external projects.CI experience: enabling IPO in all Build.yml entries made hosted and Linux jobs take 2-3+ hours longer (e.g. linux-arm with the gold linker 12 min -> 3h15; macos-26 1h25 -> 3h34; mac-arm64-elastix 22 min -> 1h19), and some jobs were killed or timed out. MSVC (v142 and v143 ARM64) hits an internal compiler error (C1001) linking ITK's
itkTestDriverwith link-time code generation, and a GCC full-IPO link of the Python/Java wrappers with Elastix needs about 19 GB of RAM, which exceeds the 16 GB runners. Hence only one CI entry uses IPO here. The experiment of enabling IPO in the release packaging workflow is in #2772.AI assistance
Developed with GitHub Copilot assistance; the changes and measurements were reviewed by the author.