diff options
author | Ian Lynagh <igloo@earth.li> | 2010-09-05 00:18:07 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2010-09-05 00:18:07 +0000 |
commit | 3bd221eb8b0964df5f3159c4970610047c2b8910 (patch) | |
tree | d259d138e350daeea60f0cdbe9741d98176eb942 /driver | |
parent | 661a63b6b427ace7e1501dc9101f2c8432b0ab5d (diff) | |
download | haskell-3bd221eb8b0964df5f3159c4970610047c2b8910.tar.gz |
Fix gcc wrapper for new mingw binaries
Diffstat (limited to 'driver')
-rw-r--r-- | driver/gcc/gcc.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/driver/gcc/gcc.c b/driver/gcc/gcc.c index 059fbd4142..e68d4a15b9 100644 --- a/driver/gcc/gcc.c +++ b/driver/gcc/gcc.c @@ -8,14 +8,40 @@ #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; + 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"); + } + /* 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. */ |