Skip to content

Commit

Permalink
pass -B flag to help gcc find libraries on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dias committed Aug 27, 2008
1 parent 20efbdd commit 28ad32e
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions Distribution/Simple/GHC.hs
Expand Up @@ -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 )
Expand Down Expand Up @@ -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)
}
Expand All @@ -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
Expand All @@ -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).

Expand All @@ -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
Expand Down

0 comments on commit 28ad32e

Please sign in to comment.