Clang and -frandom-seed

Dimitry Andric dim at FreeBSD.org
Sun Nov 21 15:23:05 UTC 2010


On 2010-11-15 11:10, Erik Cederstrand wrote:
> 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.

The path should relative, to guarantee the same result for every
location you can put the source.


> Where in the build scripts would I need to add this flag? Something like:
>
> CXXFLAGS += -frandom-seed=${.TARGET}

Rather use:

CXXFLAGS+=-frandom-seed=${.IMPSRC:S/^${.CURDIR}\///}

which is rather contorted, but I see no other way to generate a relative
path. :)

Also, this generates an empty '-frandom-seed=' option for every command
that uses CXXFLAGS but isn't a compilation at all, such as most linking
commands.  It is probably not harmful, though.


More information about the freebsd-toolchain mailing list