Skip to content

[WIP] CMake: Enable IPO/LTO #597

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

[WIP] CMake: Enable IPO/LTO #597

wants to merge 1 commit into from

Conversation

ax3l
Copy link
Member

@ax3l ax3l commented Nov 12, 2019

Interprocedural optimization (IPO) also known as link-time optimization (LTO) is a great feature to reduce binary size and to improve code performance, e.g. through extended inlining.

This feature is specifically useful for modern C++ code, which is also the reason pybind11 enables it automatically for our python bindings as soon as it is detected.

We now expose this feature for the rest of the library build as well and auto-enable it when supported by the compiler.

Binary size before:

$ du -hs lib/*
1.0M    lib/libCatchMain.so
1.0M    lib/libCatchRunner.so
1.3M    lib/libopenPMD.ADIOS1.Parallel.so
1.1M    lib/libopenPMD.ADIOS1.Serial.so
2.2M    lib/libopenPMD.so
968K    lib/python3.6

and with IPO/LTO enabled (new default):

$ du -hs lib/*
876K    lib/libCatchMain.so
876K    lib/libCatchRunner.so
1.2M    lib/libopenPMD.ADIOS1.Parallel.so
1.1M    lib/libopenPMD.ADIOS1.Serial.so
1.5M    lib/libopenPMD.so
968K    lib/python3.6

@ax3l ax3l added install third party third party libraries that are shipped and/or linked frontend: C++17 labels Nov 12, 2019
@ax3l ax3l changed the title CMake: Enable IPO/LTO [WIP] CMake: Enable IPO/LTO Nov 14, 2019
@ax3l
Copy link
Member Author

ax3l commented Dec 9, 2019

Problems occur with:

  • MSVC on shared library builds (VS 2015)
  • tooling such as clang-tidy

Interprocedural optimization (IPO) also known as link-time optimization (LTO)
is a great feature to reduce binary size and to improve code performance, e.g.
through extended inlining.

This feature is specifically useful for modern C++ code, which is also the
reason pybind11 enables it automatically for our python bindings as soon as
it is detected.

We now expose this feature for the rest of the library build as well and
auto-enable it when supported by the compiler.

Binary size before:
```
$ du -hs lib/*
1.0M    lib/libCatchMain.so
1.0M    lib/libCatchRunner.so
1.3M    lib/libopenPMD.ADIOS1.Parallel.so
1.1M    lib/libopenPMD.ADIOS1.Serial.so
2.2M    lib/libopenPMD.so
968K    lib/python3.6
```
and with IPO/LTO enabled (new default):
```
$ du -hs lib/*
876K    lib/libCatchMain.so
876K    lib/libCatchRunner.so
1.2M    lib/libopenPMD.ADIOS1.Parallel.so
1.1M    lib/libopenPMD.ADIOS1.Serial.so
1.5M    lib/libopenPMD.so
968K    lib/python3.6
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend: C++17 install third party third party libraries that are shipped and/or linked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant