runtime: adjust LLVMSupport for Windows

Windows does not support weak linking.  Use an undocumented linker
feature to provide a default implementation for report_bad_alloc_error
in the case that we are not linking against LLVMSupport.
This commit is contained in:
Saleem Abdulrasool
2018-11-16 08:41:15 -08:00
parent dd12206c0b
commit 6072d9f5df

View File

@@ -16,8 +16,18 @@
// to link.
#if defined(swiftCore_EXPORTS)
namespace llvm {
#if defined(_WIN32)
extern void report_bad_alloc_error(const char *Reason, bool GenCrashDiag);
void _report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {}
#if defined(_WIN64)
#pragma comment(linker, "/alternatename:?report_bad_alloc_error@llvm@@YAXPEBD_N@Z=?_report_bad_alloc_error@llvm@@YAXPEBD_N@Z")
#else
#pragma comment(linker, "/alternatename:?report_bad_alloc_error@llvm@@YAXPBD_N@Z=?_report_bad_alloc_error@llvm@@YAXPBD_N@Z")
#endif
#else
void __attribute__((__weak__, __visibility__("hidden")))
report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {}
#endif
} // end namespace llvm
#endif