diff options
author | Duncan Coutts <duncan@well-typed.com> | 2016-10-21 14:32:02 -0700 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2016-10-21 17:21:00 -0700 |
commit | f41a8a369796985a75dd618b969292e1e7033112 (patch) | |
tree | 5880d7bf29058e60ddbc105d5cd79b0d74b8a83b /utils/ghc-pkg/Main.hs | |
parent | 6ddba64287fe07df3b2df1f3db974b03945fc07f (diff) | |
download | haskell-f41a8a369796985a75dd618b969292e1e7033112.tar.gz |
Add and use a new dynamic-library-dirs field in the ghc-pkg info
Summary:
Build systems / package managers want to be able to control the file
layout of installed libraries. In general they may want/need to be able
to put the static libraries and dynamic libraries in different places.
The ghc-pkg library regisrtation needs to be able to handle this.
This is already possible in principle by listing both a static lib dir
and a dynamic lib dir in the library-dirs field (indeed some previous
versions of Cabal did this for shared libs on ELF platforms).
The downside of listing both dirs is twofold. There is a lack of
precision, if we're not careful with naming then we could end up
picking up the wrong library. The more immediate problem however is
that if we list both directories then both directories get included
into the ELF and Mach-O shared object runtime search paths. On ELF this
merely slows down loading of shared libs (affecting prog startup time).
On the latest OSX versions this provokes a much more serious problem:
that there is a rather low limit on the total size of the section
containing the runtime search path (and lib names and related) and thus
listing any unnecessary directories wastes the limited space.
So the solution in this patch is fairly straightforward: split the
static and dynamic library search paths in the ghc-pkg db and its use
within ghc. This is a traditional solution: pkg-config has the same
static / dynamic split (though it describes in in terms of private and
public, but it translates into different behaviour for static and
dynamic linking).
Indeed it would make perfect sense to also have a static/dynamic split
for the list of the libraries to use i.e. to have dynamic variants of
the hs-libraries and extra-libraries fields. These are not immediately
required so this patch does not add it, but it is a reasonable
direction to follow.
To handle compatibility, if the new dynamic-library-dirs field is not
specified then its value is taken from the library-dirs field.
Contains Cabal submodule update.
Test Plan:
Run ./validate
Get christiaanb and carter to test it on OSX Sierra, in combination
with Cabal/cabal-install changes to the default file layout for
libraries.
Reviewers: carter, austin, hvr, christiaanb, bgamari
Reviewed By: christiaanb, bgamari
Subscribers: ezyang, Phyx, thomie
Differential Revision: https://phabricator.haskell.org/D2611
GHC Trac Issues: #12479
Diffstat (limited to 'utils/ghc-pkg/Main.hs')
-rw-r--r-- | utils/ghc-pkg/Main.hs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs index 4466f58878..063a8067d9 100644 --- a/utils/ghc-pkg/Main.hs +++ b/utils/ghc-pkg/Main.hs @@ -1112,6 +1112,7 @@ convertPackageInfoToCacheFormat pkg = GhcPkg.extraLibraries = extraLibraries pkg, GhcPkg.extraGHCiLibraries = extraGHCiLibraries pkg, GhcPkg.libraryDirs = libraryDirs pkg, + GhcPkg.libraryDynDirs = libraryDynDirs pkg, GhcPkg.frameworks = frameworks pkg, GhcPkg.frameworkDirs = frameworkDirs pkg, GhcPkg.ldOptions = ldOptions pkg, @@ -1624,6 +1625,7 @@ checkPackageConfig pkg verbosity db_stack checkDuplicateDepends (depends pkg) mapM_ (checkDir False "import-dirs") (importDirs pkg) mapM_ (checkDir True "library-dirs") (libraryDirs pkg) + mapM_ (checkDir True "dynamic-library-dirs") (libraryDynDirs pkg) mapM_ (checkDir True "include-dirs") (includeDirs pkg) mapM_ (checkDir True "framework-dirs") (frameworkDirs pkg) mapM_ (checkFile True "haddock-interfaces") (haddockInterfaces pkg) @@ -1632,7 +1634,7 @@ checkPackageConfig pkg verbosity db_stack checkExposedModules db_stack pkg checkOtherModules pkg let has_code = Set.null (openModuleSubstFreeHoles (Map.fromList (instantiatedWith pkg))) - when has_code $ mapM_ (checkHSLib verbosity (libraryDirs pkg)) (hsLibraries pkg) + when has_code $ mapM_ (checkHSLib verbosity (libraryDirs pkg ++ libraryDynDirs pkg)) (hsLibraries pkg) -- ToDo: check these somehow? -- extra_libraries :: [String], -- c_includes :: [String], |