Bug 16185 – Contents of object files are non-deterministic
Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-06-19T08:36:00Z
Last change time
2016-09-25T14:45:33Z
Assigned to
nobody
Creator
54f9byee3t32
Comments
Comment #0 by 54f9byee3t32 — 2016-06-19T08:36:10Z
When compiling an object file, the output should be deterministic. That is, if no source has changed, DMD should generate a bit-for-bit identical object file. This simple property is very useful for build systems that cache outputs.
Here is a simple test case:
// test.d
void main()
{
}
$ dmd -c test.d; md5sum test.o
06b67b4d208f584dc694c19a52a924e6
$ dmd -c test.d; md5sum test.o
3445450e1f08f0f026950eeac3379b65
Note that this does not happen if the object was compiled on the same clock second. Thus, if run twice in quick succession, the contents will be the same (it may require a few tries):
$ dmd -c test.d; md5sum test.o; dmd -c test.d; md5sum test.o
3445450e1f08f0f026950eeac3379b65 test.o
3445450e1f08f0f026950eeac3379b65 test.o
If compiling directly to an executable, the output is deterministic:
$ dmd test.d; md5sum test
1d4b786c39156f41b5c1f505940f8936 test
$ dmd test.d; md5sum test
1d4b786c39156f41b5c1f505940f8936 test
I have only tested this on Linux x86_64, but it seems likely that the problem exists on other architectures and platforms as well.
Comment #1 by ibuclaw — 2016-09-25T14:45:33Z
Duplicate of #14976
*** This issue has been marked as a duplicate of issue 14976 ***