summaryrefslogtreecommitdiff
path: root/driver/gcc
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2017-06-29 15:34:39 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2017-06-29 15:34:39 +0100
commit58c781da4861faab11e4c5804e07e6892908ef72 (patch)
tree3eee171fbd5756b479b4dab6ce7f4e3328b9d64c /driver/gcc
parent3b0e7555fafe73b157a96ca48d8ddc04ad81b231 (diff)
downloadhaskell-58c781da4861faab11e4c5804e07e6892908ef72.tar.gz
Revert "Remove the Windows GCC driver."
This reverts commit d6cecde585b0980ed8e0050c5a1d315789fb6356. The patch broke Simon PJ's Windows build, becuase he didn't have (and should not need) a separate msys2 gcc. Following an exchange on the ghc-devs list, Tamar wrote Oops, sorry, didn’t notice it because both mine and harbormaster’s msys2 have separate GCCs installed as well. I don’t see an easy fix that would also work for end user Configure based cabal installs. So I think I’ll have to go back to the drawing board for this one. You can just leave it reverted.
Diffstat (limited to 'driver/gcc')
-rw-r--r--driver/gcc/gcc.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/driver/gcc/gcc.c b/driver/gcc/gcc.c
new file mode 100644
index 0000000000..b398c5ea46
--- /dev/null
+++ b/driver/gcc/gcc.c
@@ -0,0 +1,66 @@
+
+/* gcc on mingw is hardcoded to use /mingw (which is c:/mingw) to
+ find various files. If this is a different version of mingw to the
+ one that we have in the GHC tree then things can go wrong. We
+ therefore need to add various -B flags to the gcc commandline,
+ so that it uses our in-tree mingw. Hence this wrapper. */
+
+#include "cwrapper.h"
+#include "getLocation.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char** argv) {
+ char *binDir;
+ char *exePath;
+ char *preArgv[4];
+ char *oldPath;
+ char *newPath;
+ char *base;
+ char *version;
+ int n;
+
+ binDir = getExecutablePath();
+ exePath = mkString("%s/realgcc.exe", binDir);
+
+ /* We need programs like
+ inplace/mingw/libexec/gcc/mingw32/4.5.0/cc1.exe
+ to be able to find the DLLs in inplace/mingw/bin, so we need to
+ add it to $PATH */
+ oldPath = getenv("PATH");
+ if (!oldPath) {
+ die("Couldn't read PATH\n");
+ }
+ n = snprintf(NULL, 0, "PATH=%s;%s", binDir, oldPath);
+ n++;
+ newPath = malloc(n);
+ if (!newPath) {
+ die("Couldn't allocate space for PATH\n");
+ }
+ snprintf(newPath, n, "PATH=%s;%s", binDir, oldPath);
+ n = putenv(newPath);
+ if (n) {
+ die("putenv failed\n");
+ }
+
+ /* GCC Version. */
+ version = mkString("%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
+
+ /* Without these -B args, gcc will still work. However, if you
+ have a mingw installation in c:/mingw then it will use files
+ from that in preference to the in-tree files. */
+ preArgv[0] = mkString("-B%s", binDir);
+ preArgv[1] = mkString("-B%s/../lib", binDir);
+#if defined(__MINGW64__)
+ base = mkString("x86_64-w64-mingw32");
+#else
+ base = mkString("i686-w64-mingw32");
+#endif
+
+ preArgv[2] = mkString("-B%s/../lib/gcc/%s/%s" , binDir, base, version);
+ preArgv[3] = mkString("-B%s/../libexec/gcc/%s/%s", binDir, base, version);
+
+ run(exePath, 4, preArgv, argc - 1, argv + 1);
+}
+