[compiler-rt] [compiler-rt] Retain sanitizer callbacks with MinGW GCC (PR #222711)
Thurston Dang via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 11:03:12 PDT 2026
================
@@ -71,12 +71,20 @@
__pragma(comment(linker, "/alternatename:" WIN_SYM_PREFIX STRINGIFY(Name) "="\
WIN_SYM_PREFIX STRINGIFY(Default)))
-#define WIN_FORCE_LINK(Name) \
- __pragma(comment(linker, "/include:" WIN_SYM_PREFIX STRINGIFY(Name)))
-
-#define WIN_EXPORT(ExportedName, Name) \
- __pragma(comment(linker, "/export:" WIN_EXPORT_PREFIX STRINGIFY(ExportedName)\
- "=" WIN_EXPORT_PREFIX STRINGIFY(Name)))
+# if !defined(__GNUC__) || defined(__clang__)
+# define WIN_FORCE_LINK(Name) \
+ __pragma(comment(linker, "/include:" WIN_SYM_PREFIX STRINGIFY(Name)))
+# else
+# define WIN_FORCE_LINK(Name) \
+ extern "C" __typeof__(Name) Name; \
+ static __attribute__((used)) __typeof__(&Name) __force_link_##Name = \
+ &Name;
+# endif
+
+# define WIN_EXPORT(ExportedName, Name) \
+ __pragma(comment( \
+ linker, "/export:" WIN_EXPORT_PREFIX STRINGIFY( \
+ ExportedName) "=" WIN_EXPORT_PREFIX STRINGIFY(Name)))
----------------
thurstond wrote:
Leave out this whitespace/formatting-only change - it makes the patch look more complicated than it is.
("Avoid committing formatting- or whitespace-only changes outside of code you plan to make subsequent changes to. Also, try to separate formatting or whitespace changes from functional changes, either by correcting the format first (ideally) or afterward." -- https://llvm.org/docs/DeveloperPolicy.html)
https://github.com/llvm/llvm-project/pull/222711
More information about the llvm-commits
mailing list