summaryrefslogtreecommitdiff
path: root/rts/Linker.c
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2016-09-01 21:30:07 +0100
committerTamar Christina <tamar@zhox.com>2016-09-01 21:31:52 +0100
commite5ecb2010514405ac1b9b1285a8a65c00a5fd4e0 (patch)
tree866ae612180fb7fab7af9281d8f43980ec6718e1 /rts/Linker.c
parentf233f00b1915ac6c0a200b8017a9f07deefd401e (diff)
downloadhaskell-e5ecb2010514405ac1b9b1285a8a65c00a5fd4e0.tar.gz
Added support for deprecated POSIX functions on Windows.
Summary: With the introduction of 8.0.1 We've stopped supporting in GHCi the use of POSIX functions under their deprecated names on Windows. This to be compatible with object and libraries from the most popular compilers on the platform (Microsoft and Intel compilers). However this brings a confusing disparity between the compiled and interpreted behavior since MingW-W64 does support the deprecated names. Also It seems clear that package writers won't update their packages to properly support Windows. As such I have added redirects in the RTS for the deprecated functions as listed on https://msdn.microsoft.com/en-us/library/ms235384.aspx. This won't export the functions (as in, they won't be in the symbol table of compiled code for the RTS.) but we inject them into the symbol table of the dynamic linker at startup. Test Plan: ./validate and make test TEST="ffi017 ffi021" Reviewers: thomie, simonmar, RyanGlScott, bgamari, austin, hvr, erikd Reviewed By: simonmar, bgamari Subscribers: RyanGlScott, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D2500 GHC Trac Issues: #12209, #12497, #12496
Diffstat (limited to 'rts/Linker.c')
-rw-r--r--rts/Linker.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index b41bc1a641..f16fb83996 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -722,6 +722,7 @@ initLinker_ (int retain_cafs)
initMutex(&dl_mutex);
#endif
#endif
+
symhash = allocStrHashTable();
/* populate the symbol table with stuff from the RTS */
@@ -1369,6 +1370,18 @@ static SymbolAddr* lookupSymbol_ (SymbolName* lbl)
return NULL;
# endif
} else {
+#if defined(mingw32_HOST_OS)
+ // If Windows, perform initialization of uninitialized
+ // Symbols from the C runtime which was loaded above.
+ // We do this on lookup to prevent the hit when
+ // The symbol isn't being used.
+ if (pinfo->value == (void*)0xBAADF00D)
+ {
+ char symBuffer[50];
+ sprintf(symBuffer, "_%s", lbl);
+ pinfo->value = GetProcAddress(GetModuleHandle("msvcrt"), symBuffer);
+ }
+#endif
SymbolAddr* val = pinfo->value;
IF_DEBUG(linker, debugBelch("lookupSymbol: value of %s is %p\n", lbl, val));