On 14/07/2019 04:08, J. Gareth Moreton wrote: > Just a thought that I'd chuck in on this... I did wonder how practical > it would be to store checksums of all compiled procedures and the like > and to look for collisions. When studying how the compiler is built, I > noticed a lot of the internal methods, due to conditional defines, would > compile into identical code, so merging them would reduce the binary > size if the linker is able to strip out procedures that are never > called. Granted, I haven't done research on how Free Pascal does Whole > Program Optimisation yet, especially as it requiring a separate > compilation pass has always put me off. I would have thought that the > linker should be able to handle it right there and then because it has > all the information it needs.
Optimising linkers that do this exist. However, it's tricky to do it in a safe way because programs may compare addresses of functions to determine what to do. If those addresses become equal, program behaviour can change. E.g. procedure test1; begin end; procedure test2; begin end; procedure doit(proc: tprocedure); begin if proc=@test1 then writeln('test1') else writeln('test2'); end; begin doit(@test1); doit(@test2); end. Jonas _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel