From 8c25a5155e6e1873b409f7f595acd347a427488a Mon Sep 17 00:00:00 2001 From: Duncan Coutts Date: Tue, 29 Jul 2008 19:57:14 +0000 Subject: [PATCH] Do the ghc rts ldOptions hack in a slightly more hygenic way --- Distribution/Simple/PreProcess.hs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Distribution/Simple/PreProcess.hs b/Distribution/Simple/PreProcess.hs index 162165a6d44..54dd39a26b8 100644 --- a/Distribution/Simple/PreProcess.hs +++ b/Distribution/Simple/PreProcess.hs @@ -58,7 +58,7 @@ module Distribution.Simple.PreProcess (preprocessSources, knownSuffixHandlers, import Distribution.Simple.PreProcess.Unlit (unlit) import Distribution.Package - ( Package(..), PackageName(..), packageName ) + ( Package(..), PackageName(..) ) import Distribution.ModuleName (ModuleName) import qualified Distribution.ModuleName as ModuleName import Distribution.PackageDescription as PD @@ -67,7 +67,7 @@ import Distribution.PackageDescription as PD import qualified Distribution.InstalledPackageInfo as Installed ( InstalledPackageInfo_(..) ) import qualified Distribution.Simple.PackageSet as PackageSet - ( topologicalOrder ) + ( topologicalOrder, lookupPackageName, insert ) import Distribution.Simple.Compiler ( CompilerFlavor(..), Compiler(..), compilerFlavor, compilerVersion ) import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..)) @@ -377,20 +377,22 @@ ppHsc2hs bi lbi = standardPP lbi hsc2hsProgram $ | pkg <- pkgs , opt <- [ "-L" ++ opt | opt <- Installed.libraryDirs pkg ] ++ [ "-l" ++ opt | opt <- Installed.extraLibraries pkg ] - ++ [ opt | -- We don't link in the actual Haskell - -- libraries of our dependencies, so the - -- -u flags in the ldOptions of the rts - -- package mean linking fails on OS X. - -- Thus if we are using GHC, and if the - -- package is rts, then we don't put the - -- ldOptions in - (compilerFlavor (compiler lbi) /= GHC) || - (packageName pkg /= PackageName "rts"), - opt <- Installed.ldOptions pkg ] ] + ++ [ opt | opt <- Installed.ldOptions pkg ] ] where - pkgs = PackageSet.topologicalOrder (installedPkgs lbi) + pkgs = PackageSet.topologicalOrder (packageHacks (installedPkgs lbi)) Just gccProg = lookupProgram gccProgram (withPrograms lbi) isOSX = case buildOS of OSX -> True; _ -> False + packageHacks = case compilerFlavor (compiler lbi) of + GHC -> hackRtsPackage + _ -> id + -- We don't link in the actual Haskell libraries of our dependencies, so + -- the -u flags in the ldOptions of the rts package mean linking fails on + -- OS X (it's ld is a tad stricter than gnu ld). Thus we remove the + -- ldOptions for GHC's rts package: + hackRtsPackage index = + case PackageSet.lookupPackageName index (PackageName "rts") of + [rts] -> PackageSet.insert rts { Installed.ldOptions = [] } index + _ -> error "No (or multiple) ghc rts package is registered!!" getLdOptions :: BuildInfo -> [String] getLdOptions bi = map ("-L" ++) (extraLibDirs bi)