On Thu Jan 23 21:56:30 2025 +0000, Gabriel Ivăncescu wrote:
As I said, just because it works by luck does not mean that it's the correct way to do it. The compiler is free to change the function signature or behavior if:
- it's not exported
- it knows all callers
And then what will the asm block that calls it do? Either give compile-time error with "undefined symbol" because it can't find the original function, or run-time crash because the compiler changed the function's behavior which, while correct for all C callers, is not correct for the asm block. That's because the compiler does not look into asm statements. It doesn't know it's being called from an asm block. BTW GCC does do function signature changes and cloning when optimizing. A simple case is constant propagation where a constant argument is replaced and removed (if the called function is always called with the same constant), or parameter is removed if unused and so on, but there's many more. A new GCC version or LLVM might make your patch not be enough anymore. What else do you think the "no cloning" attribute does? So just decorate **all** functions called from asm blocks, to be safe and correct with LTO.
I understand what you're saying and think you're correct, but I think there has to be a lazier way to do this correctly, instead of requiring a tedious tree-wide update for the benefit of almost nobody. This already isn't enough to result in a working `wine-preloader` if lld is used instead of bfd (it needs `-Wl,--no-relax` as well), so I'm just going to drop this for now.
Thanks for your thoughts and insight into the topic.