I cannot believe that its taken me this long to read LLVM's ThinLTO post in the necessary amount of detail to find our bugs
They literally write you need to redo LTO when any of the following hold:
- The corresponding (primary) module’s bitcode changed
- The list of imports into or exports from the module changed
- The bitcode for any module being imported from has changed
- Any global analysis result affecting either the primary module or anything it imports has changed.
We were using 3 since the beginning. I added the first part of 2.
and then more recently I added the rest of 2.