summaryrefslogtreecommitdiff
path: root/rts/RtsSymbols.c
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2016-12-09 22:00:00 -0500
committerBen Gamari <ben@smart-cactus.org>2016-12-09 22:00:46 -0500
commit17ac9b19438d5e8f6de33f99828e8c0e7c8c1129 (patch)
treea11d36f9c47bf63ee1371d6660d6e3c253a77075 /rts/RtsSymbols.c
parent2618090b67e3df00bf126a77f883ffd65d258567 (diff)
downloadhaskell-17ac9b19438d5e8f6de33f99828e8c0e7c8c1129.tar.gz
rts: Provide _lock_file in symbol table on Windows
Test Plan: Validate on Windows, ensure that linking works. Reviewers: Phyx, austin, erikd, simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2817
Diffstat (limited to 'rts/RtsSymbols.c')
-rw-r--r--rts/RtsSymbols.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
index 6dc0b6f8f7..fdfbba3d02 100644
--- a/rts/RtsSymbols.c
+++ b/rts/RtsSymbols.c
@@ -70,6 +70,27 @@
#define RTS_WIN64_ONLY(X) /**/
#endif
+/*
+ * Note [Symbols for MinGW's printf]
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * The printf offered by Microsoft's libc implementation, msvcrt, is quite
+ * incomplete, lacking support for even %ull. Consequently mingw-w64 offers its
+ * own implementation which we enable. However, to be thread-safe the
+ * implementation uses _lock_file. This would be fine except msvcrt.dll doesn't
+ * export _lock_file, only numbered versions do (e.g. msvcrt90.dll).
+ *
+ * To work around this mingw-w64 packages a static archive of msvcrt which
+ * includes their own implementation of _lock_file. However, this means that
+ * the archive contains things which the dynamic library does not; consequently
+ * we need to ensure that the runtime linker provides this symbol.
+ *
+ * It's all just so terrible.
+ *
+ * See also:
+ * https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/
+ * https://sourceforge.net/p/mingw-w64/discussion/723797/thread/55520785/
+ */
#define RTS_MINGW_ONLY_SYMBOLS \
SymI_HasProto(stg_asyncReadzh) \
SymI_HasProto(stg_asyncWritezh) \
@@ -84,7 +105,9 @@
RTS_WIN32_ONLY(SymI_HasProto(_imp___environ)) \
RTS_WIN64_ONLY(SymI_HasProto(__imp__environ)) \
RTS_WIN32_ONLY(SymI_HasProto(_imp___iob)) \
- RTS_WIN64_ONLY(SymI_HasProto(__iob_func))
+ RTS_WIN64_ONLY(SymI_HasProto(__iob_func)) \
+ /* see Note [Symbols for MinGW's printf] */ \
+ SymI_HasProto(_lock_file)
#define RTS_MINGW_COMPAT_SYMBOLS \
SymI_HasProto_deprecated(access) \