How safe is it to turn LTO on?

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
User avatar
revolting_peasant
Posts: 247
Joined: May 29th, 2012, 5:45 pm

How safe is it to turn LTO on?

Post by revolting_peasant »

I noticed that, when I CMake-configure Wesnoth for building, LTO is turned off by default. Is this because it's somehow unsafe/unstable? If it is, can someone describe what behavior one can expect with LTO turned on?
User avatar
Pentarctagon
Project Manager
Posts: 5800
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: How safe is it to turn LTO on?

Post by Pentarctagon »

It's basically just another level of optimization, and the more you tell a compiler to optimize something the more likely it is to do something unintended because of some undefined behavior in the code base. It should be relatively safe though - the Steam Linux build has had LTO enabled for years now.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
ahyangyi
Posts: 41
Joined: February 9th, 2010, 1:00 pm

Re: How safe is it to turn LTO on?

Post by ahyangyi »

LTO also tends to make building longer (a very slow linking step that cannot be relieved by parallelism). So turning off LTO by default could have much more benign reasons.
User avatar
egallager
Posts: 667
Joined: November 19th, 2020, 7:27 pm
Location: Concord, New Hampshire
Contact:

Re: How safe is it to turn LTO on?

Post by egallager »

ahyangyi wrote: March 8th, 2026, 12:24 pm LTO also tends to make building longer (a very slow linking step that cannot be relieved by parallelism). So turning off LTO by default could have much more benign reasons.
GCC does actually support parallelism for LTO; see documentation of the -flto= option.
ahyangyi
Posts: 41
Joined: February 9th, 2010, 1:00 pm

Re: How safe is it to turn LTO on?

Post by ahyangyi »

Nice!
Post Reply