1

我正在尝试使用-fprofile-generate标志对我的代码运行配置文件引导优化。当我用它编译时,我收到以下错误。

obj\Debug\main.o||In function ZNSt10_HashtableIiSt4pairIKiiESaIS2_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEE5clearEv':| c:\program files (x86)\gfortran\lib\gcc\mingw32\4.10.0\include\c++\bits\hashtable.h|1937|undefined reference to __gcov_indirect_call_profiler_v2'| c:\program files (x86)\gfortran\lib\gcc\mingw32\4.10.0\include\c++\bits\hashtable.h|1937|undefined reference to __gcov_indirect_call_callee'| c:\program files (x86)\gfortran\lib\gcc\mingw32\4.10.0\include\c++\bits\hashtable.h|1937|undefined reference to __gcov_time_profiler'| c:\program files (x86)\gfortran\lib\gcc\mingw32\4.10.0\include\c++\bits\hashtable.h|1942|undefined reference to __gcov_one_value_profiler'| c:\program files (x86)\gfortran\lib\gcc\mingw32\4.10.0\include\c++\bits\hashtable.h|1942|undefined reference to __gcov_average_profiler'| c:\program files (x86)\gfortran\lib\gcc\mingw32\4.10.0\include\c++\bits\hashtable.h|1942|undefined reference to __gcov_ior_profiler'|

中还有其他错误消息,但所有这些都与__gcov

我无法在网上找到任何关于此的内容。有人可以帮忙吗?我在 Windows 上使用 g++ 8.1.0 并使用-march=native,-std=c++14-ffast-math标志。-fprofile-generate该程序在没有标志的情况下完全符合并运行良好。

4

1 回答 1

0

尝试在我的这个问题的末尾进行编辑以获得一种可能性:我如何获得 gcc 配置文件引导的优化以在“优化”后停止写入文件?

编辑:nvm,我试图删除标志,它在运行时而不是编译时崩溃。我不明白这应该怎么不写文件。

编辑2:我在我的情况下找到了原因,这可能和你的一样。

makefile 'make clean' 并未清除目录中的所有 .o 文件,因此在配置文件采样构建(在 LDFlags 中使用 gcov,或者更准确地说,fprofile-generate 将其拉入)和配置文件之间 -优化构建存在链接器试图拉入的剩余 .o 文件,因为源“没有改变”,文件具有错误的依赖关系。

确保在第二次优化构建之前删除您的 .o 和 .d 文件。

于 2020-05-11T16:27:17.247 回答