[fpc-pascal] When are used units recompiled? (more details)
T.Verhoeff at tue.nl
Wed Apr 5 23:37:53 CEST 2006
On Wed, Apr 05, 2006 at 01:27:04PM +0200, Jonas Maebe wrote:
> On 5 apr 2006, at 13:22, Tom Verhoeff wrote:
> >In a programming course that I teach, some students are using
> >instead of Delphi. I made available two precompiled units, that
> >is, the
> >*.ppu and *.o files. However, when the students tried to compile
> >programs using these units, the compiler complained that it could not
> >find the *.pas files. When compiling with -va (verbose all), it
> >apparent that the compiler disliked something about the *.ppu files.
> >(Sorry, I didn't get the exact message from the students.)
> Without the exact message it's hard to tell.
Here are the relevant lines from -vaa (but -vu would have provided that
Unitsearch: Fig0.ppu Searching file Fig0.ppu... found PPU Loading Fig0.ppu (FIG0) PPU Name: Fig0.ppu (FIG0) PPU Source: Fig0.pas not found (FIG0) Recompiling Fig0, checksum changed for System
The target OS is correct (I have made that mistake before, and the
resulting error message is clear).
The message "checksum changed for System" is not so clear. Now that I
think of it (especially with System capitalized), it seems to imply that
the compiled unit (Fig0.ppu) depends on the unit System, and when the
unit System accessible by the compiler when finding Fig0.ppu differs from
the checksum of the unit System used to compile Fig0.ppu, it triggers
an automatic recompile of the unit begin loaded.
It would certainly have helped me if the word "unit" was prepended to
"System". Furthermore, the checksum did not "change" (there are two
separate contexts; neither of which changed), but it differs from
the one used to compile the unit being loaded. Thus, a better message
might be: "checksum of current unit System differs from the one used
to compile unit Fig0.ppu", or "unit Fig0.ppu was compiled with an
incompatible System unit".
> >Can someone explain to me under what circumstances FPC will
> >(attempt to)
> >recompile a unit for which *.ppu and *.o are already available?
> >I couldn't find this in the documentation.
Apparently, there is a dependency on the System unit, and incompatibility
between System units can cause a recompile. Any other such dependencies?
Is every separately compiled unit dependent on System? If not, under
what circumstances will it depend on System? And on what other units?
> There are lots of possible reasons. The main ones are
> 1) sources with the same name as those used in a unit are found, and
> they are more recent than the ppu files
This was not the case.
> 2) incompatible ppu files because the internal structure changed and
> the internal version number was increased
Also this was not the case (the message would have been clearer).
> Cause 1) can be solved by compiling using the -Ur switch.
Good point. I will certainly do that in the future.
> >Versions: I used FPC 2.0.1 to compile the units; the students
> >used FPC 2.0.2 to compiler their programs.
> It's quite possible that your 2.0.1 uses a different ppu format than
> the 2.0.2 release.
That sounds rather vague. From my analysis above, it seems that updating
your System unit will invalidate all (?) precompiled units (at least
the ones that somehow "depend" on it). Or am I missing something here?
Well, I did learn something. I hope it was useful for others as well.
E-MAIL: T.Verhoeff @ TUE.NL | Fac. of Math. & Computing Science
PHONE: +31 40 247 41 25 | Eindhoven University of Technology
FAX: +31 40 247 54 04 | PO Box 513, NL-5600 MB Eindhoven
http://www.win.tue.nl/~wstomv/ | The Netherlands
More information about the fpc-pascal