gcc-4.9.1 generating different code between two successive builds
Hi, I am busy trying to generate a package for gcc that is consistent between two successive builds, and I am now down to the final few files. I am stuck with the file: cilk-abi-cilk-for.o, which is obviously built with -O2, but between two successive builds, the assembly code generated is different. Please refer to [1] for output and details. Would anyone have any suggestions that I might be able to try to get the file to generate the same assembly code? Regards /Cole [1] https://gist.github.com/anonymous/293f85221aee2b24b356
Re: gcc-4.9.1 generating different code between two successive builds
HI Martin, Thanks very much for the suggestions as well as all the information about the qsort issues. Did you ever publish your changes as a patch, or create a write up about what was necessary to create a reproducible build? I would be interested to see what others have done, and potentially anything else I may have missed. Thanks /Cole On 21 December 2015 at 21:08, Martin Sebor wrote: > On 12/20/2015 11:39 PM, Cole wrote: >> >> Hi, >> >> I am busy trying to generate a package for gcc that is consistent >> between two successive builds, and I am now down to the final few >> files. >> >> I am stuck with the file: cilk-abi-cilk-for.o, which is obviously >> built with -O2, but between two successive builds, the assembly code >> generated is different. Please refer to [1] for output and details. >> >> Would anyone have any suggestions that I might be able to try to get >> the file to generate the same assembly code? > > > It's been some time since I had to deal with this problem and > my recollection is somewhat fuzzy and probably inaccurate. IIRC, > part of it was caused by qsort being unstable (I think that was > on Solaris). We replaced it with a stable version. Another part > of it might have been caused by changes in the address space > layout caused by ASLR (causing differences in hash values used > by the register allocator or something like that). We disabled > ASLR to get around that (and other problems). With that, we had > fully repeatable builds. This was in the GCC 4.5 time frame. > With newer versions, there's also LTO that can affect things. > The -frandom-seed= option exists to make it possible to emit > identical object files that might otherwise be different. > > Martin >
Re: gcc-4.9.1 generating different code between two successive builds
I will investigate next week, and have a look at whether ASLR is turned off in our build system. But if it was on, I would expect more than a single .o file to be different. At this point in time, by disabling libcilkrts, and one other option, I can't remember which right now, I can get gcc building reproducibly. With regards to the libcilkrts library, there is only a single .o file that is being generated that differs each time. When running it through objdump, the differences always seem to pop up in the same function if I am not mistaken, and the actual assembly generated differs. Normally from the very beginning of the register initialisation. On 31 December 2015 at 12:17, Andrew Haley wrote: > On 30/12/15 15:33, Georg-Johann Lay wrote: > >> Some parts of the compiler use the address of objects to compute >> hashes, but I don't remember which part(s) actually do this. That >> technique can lead to different code for different runs of the >> compiler even on the same system. This is hard to reproduce as it >> depends on how the OS is supplying memory, and it might depend on >> the "history" of the machine and the actual OS. > > ... and many Linux kernels deliberately randomize memory layout to > provide some protection from buffer overflow attacks. > > Andrew.