[commit: ghc] master: rts: Provide _lock_file in symbol table on Windows (17ac9b1)

git at git.haskell.org git at git.haskell.org
Sat Dec 10 03:33:22 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/17ac9b19438d5e8f6de33f99828e8c0e7c8c1129/ghc

>---------------------------------------------------------------

commit 17ac9b19438d5e8f6de33f99828e8c0e7c8c1129
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Fri Dec 9 22:00:00 2016 -0500

    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


>---------------------------------------------------------------

17ac9b19438d5e8f6de33f99828e8c0e7c8c1129
 rts/RtsSymbols.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
index 6dc0b6f..fdfbba3 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)                   \



More information about the ghc-commits mailing list