public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* -frandom-seed
@ 2009-03-10 20:18 Michael Morrell
  2009-03-11  0:14 ` -frandom-seed Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Morrell @ 2009-03-10 20:18 UTC (permalink / raw)
  To: gcc-help


I want g++ to produce an identical binary when given the same source.  If I don't use __DATE__ or __TIME__, I believe this will happen with one exception.  Certain symbols get a randomly created component in their names which I can eliminate using an option like -frandom-seed=0.

However, the man page wasn't clear as to why this option was needed and made
me a little nervous anout using it.  Can someone give me a test case where
using -frandom-seed will break things?

Thanks,

  Michael


      

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: -frandom-seed
  2009-03-10 20:18 -frandom-seed Michael Morrell
@ 2009-03-11  0:14 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2009-03-11  0:14 UTC (permalink / raw)
  To: morrell; +Cc: gcc-help

Michael Morrell <morrell@alumni.ucsd.edu> writes:

> I want g++ to produce an identical binary when given the same source.
> If I don't use __DATE__ or __TIME__, I believe this will happen with
> one exception.  Certain symbols get a randomly created component in
> their names which I can eliminate using an option like
> -frandom-seed=0.
>
> However, the man page wasn't clear as to why this option was needed and made
> me a little nervous anout using it.  Can someone give me a test case where
> using -frandom-seed will break things?

With gcc 4.3 and later I think it's pretty hard to break things using
-frandom-seed, as gcc now turns functions defined in anonymous
namespaces into static symbols.  You may be able to confuse the debugger
by having multiple static functions with the same name.

Anyhow, you will always be safe if you compile each file using a
different value for -frandom-seed.  The easiest way to do that is to use
the filename itself as the seed.  The random seed can be any string.

Ian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-03-11  0:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-10 20:18 -frandom-seed Michael Morrell
2009-03-11  0:14 ` -frandom-seed Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).