1

I've noticed that if I compile binaries back to back on the machine/env with identical settings, the resulting binaries will have different MD5/SHA1 signatures, even if they are the exact same size.

I was wondering if anyone knew why that would be? Should the compiler not have identical results with identical inputs?

I've noticed this both on Linux and in Visual Studio.

sepp2k
  • 363,768
  • 54
  • 674
  • 675
thebunnyrules
  • 1,520
  • 15
  • 22
  • 4
    The most common explanation is that certain header fields can contain time stamps for when the binary was built. – 500 - Internal Server Error Feb 01 '17 at 00:17
  • Yeah, that would definitely make sense. I guess one could verify this theory by compiling a hello world cpp program with no header files to see if the outputted binary is the same – thebunnyrules Feb 01 '17 at 03:38
  • 3
    Actually, I was referring to the binary header that all executables have. Check out e.g. the Portable Executable specification for the Microsoft platforms. – 500 - Internal Server Error Feb 01 '17 at 03:58
  • Possible duplicate of [How to produce deterministic binary output with g++?](http://stackoverflow.com/questions/14653874/how-to-produce-deterministic-binary-output-with-g) – yugr Feb 01 '17 at 09:29
  • @500-InternalServerError This should be an answer. – yugr Nov 04 '18 at 21:01

0 Answers0