First of all that sounds like a known FPC bug. "Known" as in "it has be observed". Not sure as in "known where to fix". That said, in 3.3.1 the entire part that handles this has been reworked, so chances are, if/when a FPC 4.0 comes then that issues wont be there anymore.
As for what happens....
(Or my understanding of it / not confirmed by any compiler dev)
It is usually triggered by a combination of things.
- Almost (or Always?) a circular unit reference (in your ehlib package)
- often inlining, but maybe other optimizations
- could be an "inline" that is not in the interface section, but the implementation section
- May be something else, not an inline...
When the package is compiled normally, the compiler start loading pas, and creating ppu for them.
Each ppu contains checksums (several), of any other ppu it relies on (so that if any changes, all dependents can be found and recompiled).
With circular refs, the complier must
1- load unitA.pas, read the "uses"
2- load used unitB.pas, compile the interface block
3- in UnitB implementation sees "uses UnitA"
4- go back to UnitA compile the interface part (now knowing UnitB)
not sure, maybe compiles all of UnitA at that time)
5- Now that UnitA interface is compiled continue compile UnitB
During that it has partial ppu files. And one of them is saved with the checksum of the incomplete other. (i.e. the wrong checksum is kept, and makes it into the result).
Then when you compile, with only ppu visible => you get the "checksum changed", because it does not match.
Not finding the source is then an obvious consequence, of only seeing ppu...
2 ways of fixing tihs
a) Compile with -Ur release units, suppress the checksum checks.
b) Compile twice (without cleaning in between)
When you compile the 2nd time, the compiler finds the existing ppu. It loads them instead of compiling the pas sources (IIRC, if the timestamp is ok). So it does not compile again. Except when it finds the one that has the wrong checksum (in the "I depend on foo@check1 => but foo itself says "@check2") then it does recompile that one file. That fixes the checksum.
It may have to recompile both, but if it does, it still had the correct checksum from the existing ppu... Basically when it has the ppu to start, then it doesn't run into the "I keep the wrong ppu" issue