Clang and -frandom-seed

Erik Cederstrand erik at cederstrand.dk
Mon Nov 15 10:10:39 UTC 2010


Den 15/11/2010 kl. 00.10 skrev Dimitry Andric:

> On 2010-11-14 23:29, Erik Cederstrand wrote:
>> I noticed that two consecutive builds of (GCC-built) Clang don't produce identical binaries. This is true for clang, clang++ and tblgen. I asked on the llvm-dev list yesterday, and it turns out it's because GCC uses a random seed on some symbols. Apparently, this can be controlled with the -frandom-seed flag. I haven't tested if this is also the case for Clang-built Clang.
>> 
> [...]
> So this is all on purpose, and I think it would be a bad idea to disable
> it, unless we fully understand the consequences.
> 
> On the other hand, the requirement "The string should be different for
> every file you compile", could possibly be fulfilled.  Maybe by using
> the filename, relative to $SRCDIR, that is being compiled as "seed"?
> 
> This would be unique for each compiled file, but still give the same
> result for each build, and also be independent of the particular machine
> you are building on.

I was thinking of something along the same lines. I think we agree that it only needs to be random across files, not across builds. Someone on llvm-dev also suggested using the path (either full or relative to src/) as a seed.

Where in the build scripts would I need to add this flag? Something like:

CXXFLAGS += -frandom-seed=${.TARGET}

in src.conf?

Thanks,
Erik


More information about the freebsd-toolchain mailing list