Andrew Haley wrote:
Mattias Brändström writes:
> Andrew Haley wrote:
> > Mattias Brändström writes:
> >
> > >
> > > Why does g++ generate binaries with different checksums when I compile
> > > my project at two different occasions with the same commands?
> > >
> > > I realize that this is a fairly broad question, but I would like to know
> > > if there is anything in particular I should take into account when
> > > trying to generate binaries with the same checksum.
> >
> > There could be all manner of reasons. To begin with, diff the
> > assembly language source produced by g++ -save-temps. That'll get us
> > started.
> >
>
> Thanks for the pointer! I have now compiled my project with -save-temps,
> as you suggested, and ended up with some .s files that actually differ.
> Here is a portion of one the diffs:
>
> < call
> _ZN53_GLOBAL__N_locale_CompactLocale.cpp_9D2164D3_6D4895CA10is_integerERKN6ttutil4misc7DecimalE@PLT
> ---
> > call
> _ZN53_GLOBAL__N_locale_CompactLocale.cpp_9D2164D3_A9AF82EA10is_integerERKN6ttutil4misc7DecimalE@PLT
>
> To me it seems that this difference is related to name mangling, one
> function gets a different mangled name each time. In this case it is a
> function ( is_integer(ttutil::misc::Decimal&) ) in an anonymous namespace.
>
> My guess is that since the namespace is anonymous g++ creates a random
> name for it that will hopefully not clash with another randomly
> generated namespace name? Could this be the reason?
>
> Any ideas on how to get around this?
Try -frandom-seed=<string> Make compile reproducible using <string>
Nice! I had missed that compile option. The man page says that the seed
should be different for every file I compile. Do you know what kind of
trouble i might get into if I have the same seed for every file in my
project?
Regards,
Mattias