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-Options

 相同源码、相同编译器的两次编译结果并不是binary identical的,这是因为编译器的部分功能依赖于随机输入(比如生成一些唯一的symbol,一个例子是C++中anonymous namespace在编译的时候要生成一个随机的symbol)

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. 

 

当然还有一个原因可能是源码本身有hack,比如__DATE__...

转载于:https://www.cnblogs.com/qsort/p/3202650.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值