Hello!
I have been looking at how to make binary reproducible builds in our
project using gcc. It turns out that gcc gives functions in anonymous
namespaces symbol names that are part randomized. If I compile our
project with -frandom-seed=<some value> the random part of the symbol
name will be the same each compile. The man page of gcc tells me that I
need to use a different value for -frandom-seed for each file I compile.
However, I have done some digging around and it seems that gcc also
embeds the full path (as specified on the command line) in the symbol
name. Look here:
<command-line>
[mattias@design203 frandom-seed]$ cat foo/foo.cpp
#include "foo.hpp"
namespace
{
int x()
{
return 0;
}
}
int foo()
{
return x();
}
[mattias@design203 frandom-seed]$ gcc -frandom-seed=1 -c foo/foo.cpp
[mattias@design203 frandom-seed]$ objdump -t foo.o | grep foo_foo.cpp
00000000 g F .text 0000000a
_ZN40_GLOBAL__N_foo_foo.cpp_00000000_E2EB6CE91xEv
</command-line>
Now my question is this: if I compile my whole project by specifying the
full path of each file, would it be safe to use the same value for
-frandom-seed for every file?
Regards,
Mattias