diff options
Diffstat (limited to 'compiler/main')
-rw-r--r-- | compiler/main/DriverPipeline.hs | 2 | ||||
-rw-r--r-- | compiler/main/PackageConfig.hs | 1 | ||||
-rw-r--r-- | compiler/main/Packages.hs | 33 | ||||
-rw-r--r-- | compiler/main/SysTools.hs | 2 |
4 files changed, 32 insertions, 6 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index aec89e4e4f..b578612ac4 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -428,7 +428,7 @@ linkingNeeded dflags staticLink linkables pkg_deps = do -- next, check libraries. XXX this only checks Haskell libraries, -- not extra_libraries or -l things from the command line. - let pkg_hslibs = [ (libraryDirs c, lib) + let pkg_hslibs = [ (collectLibraryPaths dflags [c], lib) | Just c <- map (lookupInstalledPackage dflags) pkg_deps, lib <- packageHsLibs dflags c ] diff --git a/compiler/main/PackageConfig.hs b/compiler/main/PackageConfig.hs index bff8cc3aa3..23f37da64d 100644 --- a/compiler/main/PackageConfig.hs +++ b/compiler/main/PackageConfig.hs @@ -103,6 +103,7 @@ pprPackageConfig InstalledPackageInfo {..} = field "trusted" (ppr trusted), field "import-dirs" (fsep (map text importDirs)), field "library-dirs" (fsep (map text libraryDirs)), + field "dynamic-library-dirs" (fsep (map text libraryDynDirs)), field "hs-libraries" (fsep (map text hsLibraries)), field "extra-libraries" (fsep (map text extraLibraries)), field "extra-ghci-libraries" (fsep (map text extraGHCiLibraries)), diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs index e0563da10c..86a37352b0 100644 --- a/compiler/main/Packages.hs +++ b/compiler/main/Packages.hs @@ -541,7 +541,8 @@ readPackageConfig dflags conf_file = do let top_dir = topDir dflags pkgroot = takeDirectory conf_file - pkg_configs1 = map (mungePackagePaths top_dir pkgroot) proto_pkg_configs + pkg_configs1 = map (mungePackageConfig top_dir pkgroot) + proto_pkg_configs pkg_configs2 = setBatchPackageFlags dflags pkg_configs1 -- return (conf_file, pkg_configs2) @@ -580,6 +581,22 @@ setBatchPackageFlags dflags pkgs = maybeDistrustAll pkgs distrust pkg = pkg{ trusted = False } +mungePackageConfig :: FilePath -> FilePath + -> PackageConfig -> PackageConfig +mungePackageConfig top_dir pkgroot = + mungeDynLibFields + . mungePackagePaths top_dir pkgroot + +mungeDynLibFields :: PackageConfig -> PackageConfig +mungeDynLibFields pkg = + pkg { + libraryDynDirs = libraryDynDirs pkg + `orIfNull` libraryDirs pkg + } + where + orIfNull [] flags = flags + orIfNull flags _ = flags + -- TODO: This code is duplicated in utils/ghc-pkg/Main.hs mungePackagePaths :: FilePath -> FilePath -> PackageConfig -> PackageConfig -- Perform path/URL variable substitution as per the Cabal ${pkgroot} spec @@ -595,6 +612,7 @@ mungePackagePaths top_dir pkgroot pkg = importDirs = munge_paths (importDirs pkg), includeDirs = munge_paths (includeDirs pkg), libraryDirs = munge_paths (libraryDirs pkg), + libraryDynDirs = munge_paths (libraryDynDirs pkg), frameworkDirs = munge_paths (frameworkDirs pkg), haddockInterfaces = munge_paths (haddockInterfaces pkg), haddockHTMLs = munge_urls (haddockHTMLs pkg) @@ -1459,10 +1477,11 @@ collectIncludeDirs ps = nub (filter notNull (concatMap includeDirs ps)) -- | Find all the library paths in these and the preload packages getPackageLibraryPath :: DynFlags -> [PreloadUnitId] -> IO [String] getPackageLibraryPath dflags pkgs = - collectLibraryPaths `fmap` getPreloadPackagesAnd dflags pkgs + collectLibraryPaths dflags `fmap` getPreloadPackagesAnd dflags pkgs -collectLibraryPaths :: [PackageConfig] -> [FilePath] -collectLibraryPaths ps = nub (filter notNull (concatMap libraryDirs ps)) +collectLibraryPaths :: DynFlags -> [PackageConfig] -> [FilePath] +collectLibraryPaths dflags = nub . filter notNull + . concatMap (libraryDirsForWay dflags) -- | Find all the link options in these and the preload packages, -- returning (package hs lib options, extra library options, other flags) @@ -1514,6 +1533,12 @@ packageHsLibs dflags p = map (mkDynName . addSuffix) (hsLibraries p) expandTag t | null t = "" | otherwise = '_':t +-- | Either the 'libraryDirs' or 'libraryDynDirs' as appropriate for the way. +libraryDirsForWay :: DynFlags -> PackageConfig -> [String] +libraryDirsForWay dflags + | WayDyn `elem` ways dflags = libraryDynDirs + | otherwise = libraryDirs + -- | Find all the C-compiler options in these and the preload packages getPackageExtraCcOpts :: DynFlags -> [PreloadUnitId] -> IO [String] getPackageExtraCcOpts dflags pkgs = do diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs index e901bde06e..dd98883cb5 100644 --- a/compiler/main/SysTools.hs +++ b/compiler/main/SysTools.hs @@ -1584,7 +1584,7 @@ linkDynLib dflags0 o_files dep_packages pkgs <- getPreloadPackagesAnd dflags dep_packages - let pkg_lib_paths = collectLibraryPaths pkgs + let pkg_lib_paths = collectLibraryPaths dflags pkgs let pkg_lib_path_opts = concatMap get_pkg_lib_path_opts pkg_lib_paths get_pkg_lib_path_opts l | ( osElfTarget (platformOS (targetPlatform dflags)) || |