[Issue 16185] New: Contents of object files are non-deterministic
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Jun 19 01:36:10 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16185
Issue ID: 16185
Summary: Contents of object files are non-deterministic
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: 54f9byee3t32 at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list