benchmark
benchmark copied to clipboard
[FR] LTO should default to true
Is your feature request related to a problem? Please describe. BENCHMARK_ENABLE_LTO=true is recommended by the README.md. It should likely be the default if we think it is that important.
Hi @dominichamon I've created a pull request to solve this issue. Please let me know if there's anything more that should be done in the PR.
FWIW i'm not sure it's actually important, especially if benchmark
will be built into a shared library.
That's a good point. it only really matters if it's being built as a static library and then linked into a binary. #44 has some more details though:
LTO will probably bring minor benefits in such a small library, it allows optimisations to occur across internal compilation units inside a library. I've found that combined with -fvisibility=hidden it can help out quite nicely.
I like my tools to try to help out as much as they can so would happily add as many flags that can help me not write bugs. It is completely up to you and the other collaborators!
Given it has some benefit, and doesn't (i think?) have any downsides, i'm ok with this change.
So I build benchmark
from vcpkg with a custom toolchain using clang-cl. It has /clang:-flto=full
in CMAKE_C_FLAGS_RELEASE
. Unfortunally this completly removes main
from benchmark_main.lib
and lead to a fatal error when trying to run an executable linking that.