4 ms·
> If you build the same code on two different machines, using the same compiler, with the same options, then the generated binaries should be exactly the same.
by rocqua 8y ago
> If you build the same code on two different machines, using the same compiler, with the same options, then the generated binaries should be exactly the same.
There is so much context that is normally embedded into a binary that this is usually not true unless explicit measures have been taken.
Two very common sources that introduce variability are time-stamps used in the build, and environment variables such as $HOME and $USER.
- aidenn0 8y agoDon't forget the absolute paths of the source files...
- bregma 8y agoIf you're generating or modifying source code at build time (eg. adding timestamps or build IDs) then you have violated the constraints on build reproducibility.
- detaro 8y agoIf you define the problem as excluding things a large percentage of real-world build systems do by default, then it's not very interesting. The interesting part of Debian's and others work here is making this work with small, unintrusive changes to such systems.
- rbanffy 8y agoAs long as the intrusive changes are taken upstream, I've no problem with it.
- anth_anm 8y agowhat if you have a multi-threaded backend to the compiler that happens to lay down data in different orders?
- tantalor 8y agoThat's a bug. https://en.wikipedia.org/wiki/Race_condition https://en.wikipedia.org/wiki/Race_condition
- tedunangst 8y agoWhy is it a bug? I write a program to download four files. I do so in parallel. Sometimes X finishes first, sometimes Y finishes first, and the files are written to disk in a different order. Why do I want to serialize this operation?
- rbanffy 8y agoThe end result is a set of four files. You don't care about the order they are laid out on the disk and the next steps shouldn't let the order of those files influence the end result. Let's assume there is a latent bug in the compiler that gets triggered if file four is the first one. Good luck debugging that.
- anth_anm 8y agoIt's the internal structure of the files.
- tedunangst 8y agoBut parent claimed that creating a set with a different order was inherently a bug. Not that depending on the order of an unordered set was a bug.
- lixtra 8y agoWhy? Most compilers give no guarantees in which order they lay out the data. I love deterministic processes as much as everyone. But randomized approaches have their advantages too. And if a compiler has reasons to randomize output e.g. for speed than it’s a trade off to consider.