[commit: ghc] ghc-8.0: Fix Windows build after D1874 (88a370d)

git at git.haskell.org git at git.haskell.org
Mon Apr 11 00:05:21 UTC 2016


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

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/88a370ddbe28ca070ac69262cbff451b263e7f44/ghc

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

commit 88a370ddbe28ca070ac69262cbff451b263e7f44
Author: Tamar Christina <tamar at zhox.com>
Date:   Tue Feb 2 12:36:52 2016 +0100

    Fix Windows build after D1874
    
    Windows uses wchar_t* for paths. The code committed won't compile for
    Windows as the types are incorrect and the types in the branches of the
    ternary operator aren't consistent.
    
    Test Plan: ./validate --fast
    
    Reviewers: austin, rwbarton, erikd, bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1878
    
    (cherry picked from commit 01c587c03764de52cd01a3464c1a4a5c5bce7c00)


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

88a370ddbe28ca070ac69262cbff451b263e7f44
 rts/Linker.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/rts/Linker.c b/rts/Linker.c
index c225ab6..c7c61cf 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -199,6 +199,21 @@ static pathchar* pathdup(pathchar *path)
     return ret;
 }
 
+static pathchar* mkPath(char* path)
+{
+#if defined(mingw32_HOST_OS)
+    size_t required = mbstowcs(NULL, path, 0);
+    pathchar *ret = stgMallocBytes(sizeof(pathchar) * (required + 1), "mkPath");
+    if (mbstowcs(ret, path, required) == (size_t)-1)
+    {
+        barf("mkPath failed converting char* to wchar_t*");
+    }
+
+    return ret;
+#else
+    return pathdup(path);
+#endif
+}
 
 #if defined(OBJFORMAT_ELF)
 static int ocVerifyImage_ELF    ( ObjectCode* oc );
@@ -425,6 +440,7 @@ static int ghciInsertSymbolTable(
       pinfo->weak = HS_BOOL_FALSE;
       return 1;
    }
+   pathchar* archiveName = NULL;
    debugBelch(
       "GHC runtime linker: fatal error: I found a duplicate definition for symbol\n"
       "   %s\n"
@@ -439,10 +455,16 @@ static int ghciInsertSymbolTable(
       "     loaded twice.\n",
       (char*)key,
       obj_name,
-      pinfo->owner == NULL ? "(GHCi built-in symbols)" :
-      pinfo->owner->archiveMemberName ? pinfo->owner->archiveMemberName
+      pinfo->owner == NULL ? WSTR("(GHCi built-in symbols)") :
+      pinfo->owner->archiveMemberName ? archiveName = mkPath(pinfo->owner->archiveMemberName)
       : pinfo->owner->fileName
    );
+
+   if (archiveName)
+   {
+       stgFree(archiveName);
+       archiveName = NULL;
+   }
    return 0;
 }
 



More information about the ghc-commits mailing list