M0026 profile-no-lto¶
Rule: The profiles of the edit-build-test loop and the deploy profile build without LTO.
| Code | M0026 (stable, never reused) |
| Id | profile-no-lto |
| Category | repo |
| Source | spirit_level |
| Fix | by hand |
Level per tier¶
| Tier | Level | Reason |
|---|---|---|
| small | warn |
LTO in the loop's profiles turns a link of a second into minutes; it belongs in a release profile |
| small-workspace | warn |
LTO in the loop's profiles turns a link of a second into minutes; it belongs in a release profile |
| medium | warn |
LTO in the loop's profiles turns a link of a second into minutes; it belongs in a release profile |
| big | warn |
LTO in the loop's profiles turns a link of a second into minutes; it belongs in a release profile |
| ai | off | |
| embedded | off | |
| ui | off | |
| egui | off | |
| units-strict | off | |
| units-paranoid | off |
Parameters¶
| Name | Type | Default | Meaning |
|---|---|---|---|
profiles |
list of strings | ["dev", "test", "deploy"] |
profiles that build without LTO, inherited settings included |
Why¶
Link-time optimisation runs over the whole program at every link, single-threaded for fat, and an incremental build cannot reuse it. In the profiles a developer or an agent builds again and again (dev, test, and the deploy profile used to install on the developer's own machines) it turns a link of a second into minutes. Materialize cut CI from 23 minutes to 1.5 by taking LTO out of its test builds. The lint follows inherits: a deploy profile that inherits release also inherits its lto.
How to fix¶
Keep LTO, if anywhere, in release or a profile of its own for the artifacts that ship. Firmware is the exception: there LTO is part of fitting the image into flash, and the embedded tier does not enable this lint. The profiles checked are the parameter profiles.
Configure¶
[lints.profile-no-lto]
level = "deny"
profiles = ["dev", "test", "deploy"]
reason = "why this project wants it at this level"
Allow one finding in the code with // spirit-level: allow(profile-no-lto) <reason> (waivers); the code works there too, as in [lints.M0026].