X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=driver%2Fgcc%2Fgcc.c;h=ea1f480b4d31d509a91edb2571c584188630275c;hp=4efd559b6846d3ec733d9cca37e542f3c7598b78;hb=HEAD;hpb=dc5b9bd64d1c1f544e4813dc946b5a83ad304cee diff --git a/driver/gcc/gcc.c b/driver/gcc/gcc.c index 4efd559..ea1f480 100644 --- a/driver/gcc/gcc.c +++ b/driver/gcc/gcc.c @@ -7,28 +7,48 @@ #include "cwrapper.h" #include "getLocation.h" -#include -#include + #include #include -#include -#include 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. */ preArgv[0] = mkString("-B%s", binDir); preArgv[1] = mkString("-B%s/../lib", binDir); - preArgv[2] = mkString("-B%s/../lib/gcc/mingw32/3.4.5", binDir); - preArgv[3] = mkString("-B%s/../libexec/gcc/mingw32/3.4.5", binDir); + preArgv[2] = mkString("-B%s/../lib/gcc/mingw32/4.5.2", binDir); + preArgv[3] = mkString("-B%s/../libexec/gcc/mingw32/4.5.2", binDir); run(exePath, 4, preArgv, argc - 1, argv + 1); }