リンク時最適化 (Link-Time Optimization) とは?
リンク時最適化 (LTO) は、一部の最適化をリンク段階まで先送りすることで、ツールチェーンが1ファイルずつではなくプログラム全体を見渡せるようにするコンパイラ技術です。これにより、ファイル単位のコンパイルでは不可能なモジュール間のインライン化やデッドコード除去が可能になります。その結果、多くの場合より高速で小さいバイナリが得られます。
なぜ重要か
各翻訳単位を単独で最適化すると、プログラム全体が見えるときにのみ現れる機会を逃してしまいますが、LTOはそれらを取り戻します。その代償として、リンクステップが重く遅くなり、build時間を支配することがあります。チームは多くの場合、完全なLTOをリリースbuildにのみ有効化し、build時間を節約するためにCIのbuildは軽量に保ちます。
関連ガイド
What Is Incremental Linking?Incremental linking updates only the changed parts of an existing executable instead of relinking the whole b…
What Is a Compiler Cache?A compiler cache stores the output of compiling a translation unit keyed on its inputs, so an identical compi…
What Is Build Reproducibility?Build reproducibility is the property that building the same source in the same environment yields a bit-for-…