4 ms·
I always thought that big compilers (clang/gcc/msvc) have some degree of non-determinism due to myriad of optimization passes in combination with heuristics dec
by MaXtreeM 6y ago
I always thought that big compilers (clang/gcc/msvc) have some degree of non-determinism due to myriad of optimization passes in combination with heuristics deciding when and where to use certain kind of optimization. Is that true or not?
And certainly if you define deterministic compilation as always producing the same binary, this is already broken by compiler macros like "__DATE__" and randomly generated names during link-time optimization. [1]
[1] https://blog.conan.io/2019/09/02/Deterministic-builds-with-C-C++.html https://blog.conan.io/2019/09/02/Deterministic-builds-with-C...
- loeg 6y agoIt's not true. They are usually deterministic for the purpose of reproducibility. The same compiler version, flags, and sources should produce the same binary. Yes, __DATE__ in sources can break reproducibility. That does not mean compilers get carte blanche to be nondeterministic.
- hathawsh 6y agoI would think that profile-guided optimization (PGO) also makes compilation nondeterministic (unless the profile is stored for reuse.) https://en.wikipedia.org/wiki/Profile-guided_optimization https://en.wikipedia.org/wiki/Profile-guided_optimization I've been enabling PGO when building Python lately and I imagine the resulting binaries are a little different every time due to random events during profiling.