Commit 28ad32e6 authored by dias's avatar dias
Browse files

pass -B flag to help gcc find libraries on Windows

parent 20efbdd7
......@@ -101,7 +101,7 @@ import Distribution.Simple.Program
, rawSystemProgramStdout, rawSystemProgramStdoutConf, requireProgram
, userMaybeSpecifyPath, programPath, lookupProgram, updateProgram
, ghcProgram, ghcPkgProgram, arProgram, ranlibProgram, ldProgram
, gccProgram, stripProgram )
, gccProgram, stripProgram, userSpecifyArgs )
import Distribution.Simple.Compiler
( CompilerFlavor(..), CompilerId(..), Compiler(..), compilerVersion
, OptimisationLevel(..), PackageDB(..), Flag, extensionsToFlags )
......@@ -155,12 +155,13 @@ configure verbosity hcPath hcPkgPath conf = do
++ programPath ghcPkgProg ++ " is version " ++ display ghcPkgVersion
-- finding ghc's local gcc and ld is a bit tricky as it's not on the path:
let (gccProgram', ldProgram') = case buildOS of
let compilerDir = takeDirectory (programPath ghcProg)
baseDir = takeDirectory compilerDir
libDir = baseDir </> "gcc-lib"
(gccProgram', ldProgram') = case buildOS of
Windows ->
let compilerDir = takeDirectory (programPath ghcProg)
baseDir = takeDirectory compilerDir
binInstallCc = baseDir </> "gcc.exe"
binInstallLd = baseDir </> "gcc-lib" </> "ld.exe"
let binInstallCc = baseDir </> "gcc.exe"
binInstallLd = libDir </> "ld.exe"
in (gccProgram {
programFindLocation = \_ -> return (Just binInstallCc)
}
......@@ -170,8 +171,11 @@ configure verbosity hcPath hcPkgPath conf = do
_ -> (gccProgram, ldProgram)
(_, conf''') <- requireProgram verbosity gccProgram' AnyVersion conf''
let conf'''' = userSpecifyArgs "hsc2hs" ["--cflag=-B" ++ libDir, "--lflag=-B" ++ libDir]
conf'''
-- we need to find out if ld supports the -x flag
(ldProg, conf'''') <- requireProgram verbosity ldProgram' AnyVersion conf'''
(ldProg, conf''''') <- requireProgram verbosity ldProgram' AnyVersion conf''''
tempDir <- getTemporaryDirectory
ldx <- withTempFile tempDir ".c" $ \testcfile testchnd ->
withTempFile tempDir ".o" $ \testofile testohnd -> do
......@@ -187,10 +191,10 @@ configure verbosity hcPath hcPkgPath conf = do
return True
`catchIO` (\_ -> return False)
`catchExit` (\_ -> return False)
let conf''''' = updateProgram ldProg {
let conf'''''' = updateProgram ldProg {
programArgs = if ldx then ["-x"] else []
} conf''''
-- Yeah yeah, so obviously conf''''' is totally rediculious and the program
} conf'''''
-- Yeah yeah, so obviously conf'''''' is totally rediculious and the program
-- configuration needs to be in a state monad. That is exactly the plan
-- (along with some other stuff to give Cabal a better DSL).
......@@ -213,7 +217,7 @@ configure verbosity hcPath hcPkgPath conf = do
compilerId = CompilerId GHC ghcVersion,
compilerExtensions = languageExtensions
}
return (comp, conf''''')
return (comp, conf'''''')
-- | Given something like /usr/local/bin/ghc-6.6.1(.exe) we try and find a
-- corresponding ghc-pkg, we try looking for both a versioned and unversioned
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment