On 27/06/2026 16:02, peter green wrote:
On 27/06/2026 15:47, Mazen Neifer wrote:

I've tried to investigate this issues and came to the following conclusion 
based on multiple analysis about what is causing the non-reproducibility in the 
|lcl.chm| build.

The Compiled HTML Help (CHM) generation process uses FPC's built-in 
|chmwriter.pas| (which is compiled into the |fpdoc| utility). It has two 
runtime calls to |*SysUtils.Now*| that embed timestamps into the binary:

 1. *CHM Header:* |*TITSFWriter.InitITSFHeader*| sets |*TimeStamp := 
NToBE(MilliSecondOfTheDay(Now));*|
 2. *System Stream:* |*TChmWriter.WriteSYSTEM*| sets a metadata entry with 
|*FSection0.WriteDWord(NToLE(MilliSecondOfTheDay(Now)));*|

Because these calls use the system clock at runtime, the generated CHM files 
differ byte-for-byte depending on the exact millisecond they are built. Setting 
the |*SOURCE_DATE_EPOCH*| environment variable has no effect because 
|*SysUtils.Now*| is a standard FPC runtime function and does not read it.--

So presumablly the fix would be to patch said generator so it does understand
SOURCE_DATE_EPOCH.


Using SOURCE_DATE_EPOCH was part of the solution,
but there were also several instances of uninitialised stack variables,
which caused some random bytes to appear in the .chm files.

Full story here;
https://gitlab.com/freepascal.org/fpc/source/-/work_items/41803

Reply via email to