gcc -frandom-seed

-frandom-seed=string
     This option provides a seed that GCC uses when it would otherwise
     use random numbers. It is used to generate certain symbol names
     that have to be different in every compiled file.  It is also used
     to place unique stamps in coverage data files and the object files
     that produce them. You can use the -frandom-seed option to produce
     reproducibly identical object files.

     The string should be different for every file you compile.

http://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Debugging-Options.html#Debugging-Optionshtml

 相同源碼、相同編譯器的兩次編譯結果並非binary identical的,這是由於編譯器的部分功能依賴於隨機輸入(好比生成一些惟一的symbol,一個例子是C++中anonymous namespace在編譯的時候要生成一個隨機的symbol)dom

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. ide

 

固然還有一個緣由多是源碼自己有hack,好比__DATE__...ui

相關文章
相關標籤/搜索