Repository navigation
Conversation
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.
Enable SimpleITK_INTERPROCEDURAL_OPTIMIZATION for the core and the Python, Java and C# wrapper builds in the Package workflow, including the manylinux scripts. Standalone language projects include the IPO module so wrappers link against IPO-built libraries consistently. In Build.yml only mac-arm64-elastix-python enables IPO, with links serialized by a Ninja job pool, to limit CI time. Co-authored-by: Copilot <[email protected]>
Use Ninja with a serialized link pool for the manylinux SuperBuild, as parallel IPO links got the runner killed. Leave IPO off for the Windows core build, where MSVC hits an internal compiler error linking ITK's itkTestDriver with link-time code generation. Co-authored-by: Copilot <[email protected]>
Ninja defaults to more jobs than cores, which exhausted the memory of the runner while compiling Elastix. Co-authored-by: Copilot <[email protected]>
A single full IPO link of the Java wrapper had lto1 killed by the OOM killer on the runner. Limit the parallelism of each link to two jobs and use Ninja with a link job pool for the SuperBuild and all wrapper builds. Co-authored-by: Copilot <[email protected]>
The macOS core builds with IPO exceed the time limit of the hosted runners, so only the Python wrappers use IPO there, as on Windows. The GCC IPO link of the manylinux wrappers needs about 20GB of memory, which exceeds the memory of the runners, so add swap space. Co-authored-by: Copilot <[email protected]>
Each IPO link of an example or unit test executable took minutes, and the Python wrapper builds linked about 40 examples per wheel, which exceeded the job time limit. The wheel only needs the module, so do not build the SuperBuild unit tests or the examples of the wrapper builds. Co-authored-by: Copilot <[email protected]>
The Java wrapper tests need sitkCompareDriver from the SuperBuild. Co-authored-by: Copilot <[email protected]>
Member
Author
|
The CMAKE_INTERPROCEDURAL_OPTIMIZATION_${_config} can be set with out having to add the custom SimpleITK CMake option. This feature decreases run time and can not be linked with the GH provided agents and will not be used. |
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 19, 2026
Port of the SimpleITK_DEAD_STRIP option from SimpleITK (SimpleITK/SimpleITK#2784, which followed the link-time optimization study in SimpleITK/SimpleITK#2772). On Linux it compiles with -ffunction-sections -fdata-sections and links with gold --gc-sections --icf=safe. Off by default; other platforms are unchanged. A/B on ITK 957816d, manylinux_2_28 (GCC 14.2, gold 1.15), cp311 abi3: wheel off on itk_core 89.5 MB 87.0 MB itk_filtering 89.3 MB 86.4 MB itk_filtering_extra 60.3 MB 57.8 MB itk_numerics 64.7 MB 62.9 MB .text across the 96 wrapper modules fell 4.4%, against 15% in SimpleITK: _ITKCommonPython exports 33,625 symbols from its statically linked ITK libraries, and the linker must keep them all. ITK already links its wrapper modules with -flto, so link cost barely moved: the three largest modules, linked alone, took 1-4% longer and used the same peak memory (9.05 GB for _ITKImageIntensityPython). Seventeen Python cases gave bit-identical output in both arms; BSpline/LBFGSB registration ran 5-7% slower, as it did in SimpleITK, and the rest stayed within run-to-run noise. ld64 -dead_strip changed the macOS arm64 wheels by under 0.1% and is not applied there.
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 20, 2026
Port of the SimpleITK_DEAD_STRIP option from SimpleITK (SimpleITK/SimpleITK#2784, which followed the link-time optimization study in SimpleITK/SimpleITK#2772). On Linux it compiles with -ffunction-sections -fdata-sections and links with gold --gc-sections --icf=safe. Off by default; other platforms are unchanged. A/B on ITK 957816d, manylinux_2_28 (GCC 14.2, gold 1.15), cp311 abi3: wheel off on itk_core 89.5 MB 87.0 MB itk_filtering 89.3 MB 86.4 MB itk_filtering_extra 60.3 MB 57.8 MB itk_numerics 64.7 MB 62.9 MB .text across the 96 wrapper modules fell 4.4%, against 15% in SimpleITK: _ITKCommonPython exports 33,625 symbols from its statically linked ITK libraries, and the linker must keep them all. ITK already links its wrapper modules with -flto, so link cost barely moved: the three largest modules, linked alone, took 1-4% longer and used the same peak memory (9.05 GB for _ITKImageIntensityPython). Seventeen Python cases gave bit-identical output in both arms; BSpline/LBFGSB registration ran 5-7% slower, as it did in SimpleITK, and the rest stayed within run-to-run noise. ld64 -dead_strip changed the macOS arm64 wheels by under 0.1% and is not applied there.
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 20, 2026
Port of the SimpleITK_DEAD_STRIP option from SimpleITK (SimpleITK/SimpleITK#2784, which followed the link-time optimization study in SimpleITK/SimpleITK#2772). On Linux it compiles with -ffunction-sections -fdata-sections and links with gold --gc-sections --icf=safe. Off by default; other platforms are unchanged. A/B on ITK 957816d, manylinux_2_28 (GCC 14.2, gold 1.15), cp311 abi3: wheel off on itk_core 89.5 MB 87.0 MB itk_filtering 89.3 MB 86.4 MB itk_filtering_extra 60.3 MB 57.8 MB itk_numerics 64.7 MB 62.9 MB .text across the 96 wrapper modules fell 4.4%, against 15% in SimpleITK: _ITKCommonPython exports 33,625 symbols from its statically linked ITK libraries, and the linker must keep them all. ITK already links its wrapper modules with -flto, so link cost barely moved: the three largest modules, linked alone, took 1-4% longer and used the same peak memory (9.05 GB for _ITKImageIntensityPython). Seventeen Python cases gave bit-identical output in both arms; BSpline/LBFGSB registration ran 5-7% slower, as it did in SimpleITK, and the rest stayed within run-to-run noise. ld64 -dead_strip changed the macOS arm64 wheels by under 0.1% and is not applied there.
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 20, 2026
Port of the SimpleITK_DEAD_STRIP option from SimpleITK (SimpleITK/SimpleITK#2784, which followed the link-time optimization study in SimpleITK/SimpleITK#2772). On Linux it compiles with -ffunction-sections -fdata-sections and links with gold --gc-sections --icf=safe. Off by default; other platforms are unchanged. A/B on ITK 957816d, manylinux_2_28 (GCC 14.2, gold 1.15), cp311 abi3: wheel off on itk_core 89.5 MB 87.0 MB itk_filtering 89.3 MB 86.4 MB itk_filtering_extra 60.3 MB 57.8 MB itk_numerics 64.7 MB 62.9 MB .text across the 96 wrapper modules fell 4.4%, against 15% in SimpleITK: _ITKCommonPython exports 33,625 symbols from its statically linked ITK libraries, and the linker must keep them all. ITK already links its wrapper modules with -flto, so link cost barely moved: the three largest modules, linked alone, took 1-4% longer and used the same peak memory (9.05 GB for _ITKImageIntensityPython). Seventeen Python cases gave bit-identical output in both arms; BSpline/LBFGSB registration ran 5-7% slower, as it did in SimpleITK, and the rest stayed within run-to-run noise. ld64 -dead_strip changed the macOS arm64 wheels by under 0.1% and is not applied there.
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.
Adds the
SimpleITK_INTERPROCEDURAL_OPTIMIZATIONoption from #2766 (first commit) and enables it for all Package workflow builds (core, Python, Java, C#, manylinux and macOS/Windows scripts). Standalone language wrapper projects now include the IPO module so they link consistently with IPO-built libraries.In Build.yml only
mac-arm64-elastix-pythonuses IPO (links serialized via a Ninja job pool); the previous all-entries WIP is dropped. Notemac-arm64-superbuilduses build typeRelMinSize, which is not a CMake config, so IPO would not apply there.Supersedes the WIP CI commit of #2766. CI results pending.