On 26.03.2025 14:07, Martin Storsjö wrote:
On Sat, 22 Mar 2025, Jacek Caban wrote:
mingw-w64-crt implements a number of functions that the compiler
considers
built-in. Currently, we must be cautious about compiler
optimizations, as they
may not align with our intentions. In theory, the compiler could
optimize an
implementation of such a function back into a call to itself.
Rather than second-guessing the optimizer and reimplementing problematic
functions in assembly, disable built-in functions globally for
mingw-w64-crt.
---
mingw-w64-crt/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 779beab17..f49f316c6 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -20,7 +20,7 @@ else
endif
Patches 2-5 in this series, replacing memset with various struct
assignments, feel quite cryptic on their own - I think they would be
more understandable if their commit messages would explan, that it is
preparation for using -fno-builtin, which makes the compiler not
expand memset() inline.
I extended the commit message and pushed, thanks for the review.
I feel it may be hard to keep track of this going forward though; it's
easy to add another memset which doesn't get compiled the way we
expect it to. But I'm not sure if there's any other good way either...
Yes, I don't see any way to help catch those cases. I don't think it's a
big deal; there aren't many, and if we do end up emitting some memset
calls, they’ll mostly be harmless anyway.
It would be nice if we could do e.g. "-fno-builtin -fbuiltin-memset",
to enable treating memset as builtin, but not the others - but there's
no "-fbuiltin-memset". And enumerating all possible -fno-builtin-<foo>
feels messy and hard to keep track of.
Yes, it's unfortunate that we can only disable selectively, not enable.
Thanks,
Jacek
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public