Weird FUD by Phoronix about LTO builds since Mesa is apparently turning off their LTO builds due to "impossible to reproduce bugs that only happen in LTO builds". I'd like to get other people's take, but I'm assuming what's actually happening is that like with -O1 vs -O3, optimizing across translation units is exposing latent UB bugs (or much less likely, latent compiler bugs not directly related to LTO), and it's not that the LTO pass itself is buggy.
With the right adjustment in your mindset, any time you find that a bug with your code only materializes with different compilers or compiler versions or optimization flags, you're given a gift that lets you root out UB bugs in your code. Or, much more rarely, you get to root out compiler bugs, which is less fun. But having been in the situation of trying to ship things with latent UB like this, I understand the frustration. So don't ship LTO for now, but you (probably) still have serious bugs.
If you're a real psychopath you can try to fuzz your code for UB by compiling and auto-testing it with many different permutations of compilers and compiler configurations like that.
@pervognsen also if you have a reproducible issue it's probably worth reaching for `-fwrapv` and `-fno-strict-aliasing` first, since that might help you narrow it down more than reaching for the hammer that is disabling LTO.
@dotstdy Yeah, I think -fno-strict-aliasing in particular is close enough to mandatory for a lot of code bases since that's the single biggest deviation between C as actually used in practice vs the specification. So it deserves a separate category in that it's acceptable to just require it and not consider it UB in practice, so it's not really in the same category as anything else. Although -fwrapv would indeed be a close second.
@pervognsen @dotstdy
If I interpret https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/meson.build?ref_type=heads correctly, they indeed do not set -fno-strict-aliasing - bold.
meson.build · main · Mesa / mesa · GitLab

Mesa 3D graphics library

GitLab
@dotstdy @pervognsen fwiw it's no help when the compiler is rustc. For that one you do need the deranged fuzzing mentioned above 🫠
@crystalmoon @pervognsen at least there's still no tbaa!
@dotstdy @pervognsen but you have non-deduplicable Comdat sections 😭