delphilinkerbinary-reproducibility

Why does every build change the exe-file?


Building the same project (without any changes) produces binary different exe-files: some small regions of them are different. Empty project, version information (and auto-increment on every build) is turned off.

Why it happens? And is it possible to make delphi produce binary equal files for the same projects?


Solution

  • The various structures in the PE executable file format used by Windows include timestamps that are set by the compiler and linker.

    It is possible to post-process the file to reset these values to a defined constant (I wrote a tool to do exactly this for a secure product that needed exact hash values), but this should only be done on ready-to-ship executables, as some debuggers rely on the timestamps for source lookup, etc.