On Fri, 4 Nov 2022, LIU Hao wrote:

在 2022/11/1 18:18, Martin Storsjö 写道:

Attached is a patch that goes on top of this, which reverts the parts which should be strictly unnecessary (and currently are breaking Clang on i386).


I suddenly realized that this could result in infinite loops with Clang, so not sure we should accept the other parts that didn't get reverted by your patch.


My patch results in code like

 ```
 declaration of `__mingw_vsprintf`
 declaration of `vsprintf` with an asm renaming attribute
 GNU inline definition of `vsprintf`
 ```

This structure looks very similar to https://github.com/llvm/llvm-project/issues/58724#issuecomment-1298505921 and (I think) will result in infinite recursion if compiled with clang.

Yes, there's a certain risk for that. When I noticed that this indeed could create infinite loops, I was worried about the same and checked - but Clang didn't create infinite loops for these ones - at least not in the git version of Clang that I used for testing.

The reason for that is that the issue (in current git versions of Clang) only happens for non-builtin functions; when the function is a known builtin it doesn't happen. That's why I was so curious to dig into the behaviour of builtin vs non-builtin in that issue report.

But older versions of Clang do have that issue - for Clang 13, such code would trigger infinite recursion even for known builtin functions.


But I think this still is kinda safe. After my revert-patch, Clang shouldn't see any of the functions with __asm__ renames at all.

GCC needs these renamings, to allow using gnu_inline, to fix issues with __builtin_va_arg_pack(). Strictly speaking, only the functions that use __builtin_va_arg_pack() need this change. (Ideally we'd do it for others as well, but we practically can't really do it for all of them yet.)

Clang doesn't support __builtin_va_arg_pack(), so none of the function wrappers that use __builtin_va_arg_pack() should be visible to Clang right now.

So with that, I think we are safe - but we can't apply the same pattern on other functions even if that would be ideal. (We can hide it behind ifdefs if we wanted to, but that makes for even more complicated code.)

If Clang gains support for __builtin_va_arg_pack() in the future, let's hope that all these cases of infinite recursion have been resolved by then, before we unlock the __builtin_va_arg_pack() codepaths for it.

// Martin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to