Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_defs.h =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_defs.h +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_defs.h @@ -30,6 +30,16 @@ #define WIN_SYM_PREFIX #endif +// For MinGW, the /export: directives contain undecorated symbols, contrary to +// link/lld-link. The GNU linker doesn't support /alternatename and /include +// though, thus lld-link in MinGW mode interprets them in the same way as +// in the default mode. +#ifdef __MINGW32__ +#define WIN_EXPORT_PREFIX +#else +#define WIN_EXPORT_PREFIX WIN_SYM_PREFIX +#endif + // Intermediate macro to ensure the parameter is expanded before stringified. #define STRINGIFY_(A) #A #define STRINGIFY(A) STRINGIFY_(A) @@ -62,8 +72,8 @@ __pragma(comment(linker, "/include:" WIN_SYM_PREFIX STRINGIFY(Name))) #define WIN_EXPORT(ExportedName, Name) \ - __pragma(comment(linker, "/export:" WIN_SYM_PREFIX STRINGIFY(ExportedName) \ - "=" WIN_SYM_PREFIX STRINGIFY(Name))) + __pragma(comment(linker, "/export:" WIN_EXPORT_PREFIX STRINGIFY(ExportedName) \ + "=" WIN_EXPORT_PREFIX STRINGIFY(Name))) // We cannot define weak functions on Windows, but we can use WIN_WEAK_ALIAS() // which defines an alias to a default implementation, and only works when