#969 Is adding -lto an acceptable modification of default compiler flags?
Opened 2 years ago by decathorpe. Modified 2 years ago

From time to time, I see packagers enabling link-time optimizations for some packages (the most recent example is here), and I don't think that this is an acceptable modification of the default compiler flags in fedora, since according to the Packaging Guidelines tampering with the default flags is generally forbidden, unless there's a good reason to do so.

In the linked example, there's no documented reason for adding the -flto flags, the package passed review without the flags being mentioned, and my questions regarding this issue have been ignored (by both the reviewer and the reviewee) for almost two weeks now.

I think removing or altering/overriding the existing flags is what we're trying to prevent.

Obviously we can't get into just what flags are OK and what flags aren't, because gcc has probably hundreds of flags and we certainly don't want to pretend to be exhaustive. Plus some interact with others in ways I wouldn't claim to understand. Obviously Fedora's flags are chosen with great care by people who certainly know much more than I do. If you really wanted to read it that way, the existing guideline technically discourages adding, say, -o even though that's patently absurd.

Anyway, here's the specific language:

Adding to and overriding or filtering parts of these flags is permitted if there’s a good reason to do so; the rationale for doing so must be documented in the specfile.

So if it's explicitly added in a specfile, then the packager needs to say why. (Presumably it provides a performance benefit.) If upstream adds it automatically then I wouldn't interfere.

Nope, there's no explanation for modifying the build flags:


PS: The package name is also semi-invented by the packager, which I also asked about, but got no answer there either ....

Technically anybody can do anything like that. And that would even work until somebody who is working on proper LTO enablemend or reproducible builds will come and report a bug against the package. Or it will get FTBFS on the next mass rebuild.

However, the comment must be there describing WHY it has LTO enabled.

Login to comment on this ticket.