From 3bd221eb8b0964df5f3159c4970610047c2b8910 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Sun, 5 Sep 2010 00:18:07 +0000 Subject: [PATCH] Fix gcc wrapper for new mingw binaries --- configure.ac | 6 +++++- driver/gcc/gcc.c | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e10555e..a8539fb 100644 --- a/configure.ac +++ b/configure.ac @@ -453,7 +453,11 @@ then tar --lzma -xf ../../ghc-tarballs/mingw/w32api*.tar.lzma && mv bin/gcc.exe bin/realgcc.exe ) - inplace/mingw/bin/realgcc.exe driver/gcc/gcc.c driver/utils/cwrapper.c driver/utils/getLocation.c -Idriver/utils -o inplace/mingw/bin/gcc.exe + PATH=`pwd`/inplace/mingw/bin:$PATH inplace/mingw/bin/realgcc.exe driver/gcc/gcc.c driver/utils/cwrapper.c driver/utils/getLocation.c -Idriver/utils -o inplace/mingw/bin/gcc.exe + if ! test -e inplace/mingw/bin/gcc.exe + then + AC_MSG_ERROR([GHC is required unless bootstrapping from .hc files.]) + fi AC_MSG_NOTICE([In-tree mingw tree created]) fi if ! test -d inplace/perl || diff --git a/driver/gcc/gcc.c b/driver/gcc/gcc.c index 059fbd4..e68d4a1 100644 --- a/driver/gcc/gcc.c +++ b/driver/gcc/gcc.c @@ -8,14 +8,40 @@ #include "cwrapper.h" #include "getLocation.h" +#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. */ -- 1.7.10.4