gcc 编译 gcc warning 'variable tracking size limit exceeded' 原因及解决办法

gcc 编译报错:note: variable tracking size limit exceeded with -fvar-tracking-assignments, retrying without

原因: gcc (g++也有可能) 编译时调优,使用了参数“-fvar-tracking-assignments”。

大神的解释如下:

According to official documentation from GCC:
-fvar-tracking-assignments: Annotate assignments to user variables early in the compilation and attempt to carry the annotations over throughout the compilation all the way to the end, in an attempt to improve debug information while optimizing. Use of -gdwarf-4 is recommended along with it. It can be enabled even if var-tracking is disabled, in which case annotations are created and maintained, but discarded at the end. By default, this flag is enabled together with -fvar-tracking, except when selective scheduling is enabled.

From the internet as well:
On note: variable tracking size limit exceeded with -fvar-tracking-assignments, retrying without: This is just a note from the compiler that the debug info for the particular function will have lower quality, because your code of function is too large/complex so variable tracking reached limit of hash table slots.

网上找到几种解决办法:

  1. Fixed the warning by reducing the number of assignments in your program.

  2. We can increase the limit by specifying --param=max-vartrack-size=N on the command line. If I compile with --param=max-vartrack-size=60000000, the warning disappears.

  3. Another option is to completely shutdown variable assignment tracking using -fno-var-tracking-assignments option.

  4. Yeah, the only downside is the file gets compiled twice. FYI, getting this error on a large unit test .cpp. 编译两次就可以了!

本人用了第四种方法, 居然神奇地好了! 可能是第一次优化编译,部分变量被track,第二次编译时这些变量就不再被track; 或者已经编译好的文件不需再次编译了。总之,减少了需要tracing的变量数,不再超过hash table的大小限制。

参考:
https://github.com/v8mips/v8mips/issues/213
https://stackoverflow.com/questions/2954473/variable-tracking-is-eating-my-compile-time
https://stackoverflow.com/questions/23499909/adjust-variable-tracking-assignment-length
https://github.com/Beep6581/RawTherapee/issues/3543
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/developer_guide/ch-debug-vta
https://gcc.gnu.org/wiki/Var_Tracking_Assignments

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值