fix: prevent LTO from breaking settingGet/settingGetIndex round-trip#11577
Merged
sensei-hacker merged 2 commits intoMay 22, 2026
Merged
Conversation
Under INTERPROCEDURAL_OPTIMIZATION, the compiler inlines settingGet and settingGetIndex with divergent static settingsTable base addresses, causing MSPV2_SETTING to return wrong data for some settings while MSP2_COMMON_SETTING_INFO (name lookup) is correct.
Contributor
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Test firmware build ready — commit Download firmware for PR #11577 234 targets built. Find your board's
|
- Improve comment accuracy: describe observed behavior rather than the inferred mechanism; note why raw attribute is used instead of NOINLINE macro (NOINLINE is empty on non-F7/H7 targets but bug affects all LTO release builds) - Add noinline to settingGetPgn which has identical pointer arithmetic against settingsTable and is called from settingGetValuePointer - Add brief comments above settingGetIndex and settingGetPgn pointing back to the main explanation on settingGet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Under
INTERPROCEDURAL_OPTIMIZATION(LTO), the compiler inlinessettingGetandsettingGetIndexat their respective call sites with potentially divergent views ofsettingsTable's base address. The result is thatsettingGetIndex(ptr)returns index X, butsettingGet(X)does not return the same entry — breaking the round-trip.Symptom:
MSPV2_SETTINGreturns the wrong value size (e.g. 1 byte) for some settings, whileMSP2_COMMON_SETTING_INFOfor the same setting name correctly returns the expected size and value. SITL builds are not affected because SITL is excluded from LTO.Fix: Mark
settingGetandsettingGetIndexasnoinline, forcing LTO to use a single, consistent reference tosettingsTableacross all call sites.Changes
src/main/fc/settings.c: add__attribute__((noinline))tosettingGetandsettingGetIndexTesting