[commit: ghc] ghc-8.0: Fall back on ghc-stage2 when using Windows' GHCi driver (595eb24)

git at git.haskell.org git at git.haskell.org
Fri Jan 8 11:25:04 UTC 2016


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

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/595eb24f2ffb06dfac6ad619bb3abe75b59bbf44/ghc

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

commit 595eb24f2ffb06dfac6ad619bb3abe75b59bbf44
Author: RyanGlScott <ryan.gl.scott at gmail.com>
Date:   Wed Jan 6 23:10:54 2016 +0100

    Fall back on ghc-stage2 when using Windows' GHCi driver
    
    Reviewers: austin, hvr, bgamari, thomie
    
    Reviewed By: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1721
    
    (cherry picked from commit f01eb5410d7980567bf2731b9cded9a4894a3ef5)


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

595eb24f2ffb06dfac6ad619bb3abe75b59bbf44
 driver/ghci/ghci.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/driver/ghci/ghci.c b/driver/ghci/ghci.c
index 414521f..f358d96 100644
--- a/driver/ghci/ghci.c
+++ b/driver/ghci/ghci.c
@@ -3,6 +3,12 @@
 #include "getLocation.h"
 #include <stdio.h>
 #include <stdlib.h>
+#include <windows.h>
+
+BOOL fileExists(const char *path) {
+    const DWORD r = GetFileAttributesA(path);
+    return r != INVALID_FILE_ATTRIBUTES && !(r & FILE_ATTRIBUTE_DIRECTORY);
+}
 
 int main(int argc, char** argv) {
     char *binDir;
@@ -19,6 +25,13 @@ int main(int argc, char** argv) {
     exePath = mkString("%s/ghc.exe", binDir);
     preArgv[0] = "--interactive";
 
+    /* If ghc.exe can't be found, we assume that we're building ghc from
+     * source, in which case we fall back on ghc-stage2.
+     */
+    if (!fileExists(exePath)) {
+        exePath = mkString("%s/ghc-stage2.exe", binDir);
+    }
+
     run(exePath, 1, preArgv, argc - 1, argv + 1);
 }
 



More information about the ghc-commits mailing list