问题描述
对于gcc,此 answer 告诉我们如何验证链接时间优化已执行.对于clang,我看不到任何类似于.gnu.lto
的条目.
For gcc, this answer tells us how we can verify that Link-Time Optimization was performed. For clang, I cannot see any entries similar to .gnu.lto
.
更具体地说,我有一个二进制文件,我非常确定LTO应该具有显着的优势,但是我什么也没看到.我想知道cmake是否真的做对了.
More specifically, I have a binary where I am quite sure that LTO should have a significant benefit, but I am seeing nothing. I wonder if cmake actually does the right thing.
是否可以通过查看二进制文件或* .o文件来判断clang是否执行了LTO?
推荐答案
一种选择是尝试在您的.o文件之一上运行llvm-dis
.如果实际执行了LTO,则.o文件包含llvm位代码,并且llvm-dis
将生成包含人类可读的llvm ir的.ll文件.否则,将产生错误消息错误:无效的位码签名".
An option would be to try running llvm-dis
on one of your .o files. If the LTO was actually performed, the .o files contain llvm bitcode and llvm-dis
will produce the .ll file containing humain-readable llvm ir. Otherwise it will produce the error message "error: Invalid bitcode signature".
这篇关于叮当声:如何检查是否执行了LTO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!