Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cabal/Distribution/Make.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
-- @--bindir@,
-- @--libdir@,
-- @--libexecdir@,
-- @--datadir@.
-- @--datadir@,
-- @--hidir@.
--
-- [BuildCmd] We assume that the default Makefile target will build everything.
--
Expand Down
14 changes: 11 additions & 3 deletions Cabal/Distribution/Simple/Build/PathsModule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ generate pkg_descr lbi =
pragmas++
"module " ++ display paths_modulename ++ " (\n"++
" version,\n"++
" getBinDir, getLibDir, getDataDir, getLibexecDir,\n"++
" getBinDir, getLibDir, getDataDir, getHiDir, getLibexecDir,\n"++
" getDataFileName, getSysconfDir\n"++
" ) where\n"++
"\n"++
Expand Down Expand Up @@ -111,6 +111,7 @@ generate pkg_descr lbi =
"\ngetBinDir, getLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n"++
"getBinDir = "++mkGetEnvOrReloc "bindir" flat_bindirreloc++"\n"++
"getLibDir = "++mkGetEnvOrReloc "libdir" flat_libdirreloc++"\n"++
"getHiDir = "++mkGetEnvOrReloc "hidir" flat_hidirreloc++"\n"++
"getDataDir = "++mkGetEnvOrReloc "datadir" flat_datadirreloc++"\n"++
"getLibexecDir = "++mkGetEnvOrReloc "libexecdir" flat_libexecdirreloc++"\n"++
"getSysconfDir = "++mkGetEnvOrReloc "sysconfdir" flat_sysconfdirreloc++"\n"++
Expand All @@ -124,17 +125,19 @@ generate pkg_descr lbi =
"\n"++
filename_stuff
| absolute =
"\nbindir, libdir, datadir, libexecdir, sysconfdir :: FilePath\n"++
"\nbindir, libdir, datadir, hidir, libexecdir, sysconfdir :: FilePath\n"++
"\nbindir = " ++ show flat_bindir ++
"\nlibdir = " ++ show flat_libdir ++
"\ndatadir = " ++ show flat_datadir ++
"\nhidir = " ++ show flat_hidir ++
"\nlibexecdir = " ++ show flat_libexecdir ++
"\nsysconfdir = " ++ show flat_sysconfdir ++
"\n"++
"\ngetBinDir, getLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n"++
"\ngetBinDir, getLibDir, getDataDir, getHiDir, getLibexecDir, getSysconfDir :: IO FilePath\n"++
"getBinDir = "++mkGetEnvOr "bindir" "return bindir"++"\n"++
"getLibDir = "++mkGetEnvOr "libdir" "return libdir"++"\n"++
"getDataDir = "++mkGetEnvOr "datadir" "return datadir"++"\n"++
"getHiDir = "++mkGetEnvOr "hidir" "return hidir"++"\n"++
"getLibexecDir = "++mkGetEnvOr "libexecdir" "return libexecdir"++"\n"++
"getSysconfDir = "++mkGetEnvOr "sysconfdir" "return sysconfdir"++"\n"++
"\n"++
Expand All @@ -154,6 +157,8 @@ generate pkg_descr lbi =
"getDataDir :: IO FilePath\n"++
"getDataDir = "++ mkGetEnvOr "datadir"
(mkGetDir flat_datadir flat_datadirrel)++"\n\n"++
"getHiDir :: IO FilePath\n"++
"getHiDir = "++mkGetDir flat_libdir flat_hidirrel++"\n\n"++
"getLibexecDir :: IO FilePath\n"++
"getLibexecDir = "++mkGetDir flat_libexecdir flat_libexecdirrel++"\n\n"++
"getSysconfDir :: IO FilePath\n"++
Expand All @@ -174,20 +179,23 @@ generate pkg_descr lbi =
bindir = flat_bindir,
libdir = flat_libdir,
datadir = flat_datadir,
hidir = flat_hidir,
libexecdir = flat_libexecdir,
sysconfdir = flat_sysconfdir
} = absoluteInstallDirs pkg_descr lbi NoCopyDest
InstallDirs {
bindir = flat_bindirrel,
libdir = flat_libdirrel,
datadir = flat_datadirrel,
hidir = flat_hidirrel,
libexecdir = flat_libexecdirrel,
sysconfdir = flat_sysconfdirrel
} = prefixRelativeInstallDirs (packageId pkg_descr) lbi

flat_bindirreloc = shortRelativePath flat_prefix flat_bindir
flat_libdirreloc = shortRelativePath flat_prefix flat_libdir
flat_datadirreloc = shortRelativePath flat_prefix flat_datadir
flat_hidirreloc = shortRelativePath flat_prefix flat_hidir
flat_libexecdirreloc = shortRelativePath flat_prefix flat_libexecdir
flat_sysconfdirreloc = shortRelativePath flat_prefix flat_sysconfdir

Expand Down
3 changes: 2 additions & 1 deletion Cabal/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ configure (pkg_descr0', pbi) cfg = do

dirinfo "Binaries" (bindir dirs) (bindir relative)
dirinfo "Libraries" (libdir dirs) (libdir relative)
dirinfo "Interfaces" (hidir dirs) (hidir relative)
dirinfo "Private binaries" (libexecdir dirs) (libexecdir relative)
dirinfo "Data files" (datadir dirs) (datadir relative)
dirinfo "Documentation" (docdir dirs) (docdir relative)
Expand Down Expand Up @@ -2013,7 +2014,7 @@ checkRelocatable verbosity pkg lbi
all isJust
(fmap (stripPrefix p)
[ bindir, libdir, dynlibdir, libexecdir, includedir, datadir
, docdir, mandir, htmldir, haddockdir, sysconfdir] )
, hidir, docdir, mandir, htmldir, haddockdir, sysconfdir] )

-- Check if the library dirs of the dependencies that are in the package
-- database to which the package is installed are relative to the
Expand Down
5 changes: 3 additions & 2 deletions Cabal/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1115,13 +1115,14 @@ installExe verbosity lbi installDirs buildPref
installLib :: Verbosity
-> LocalBuildInfo
-> FilePath -- ^install location
-> FilePath -- ^install location for interface files
-> FilePath -- ^install location for dynamic libraries
-> FilePath -- ^Build location
-> PackageDescription
-> Library
-> ComponentLocalBuildInfo
-> IO ()
installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do
installLib verbosity lbi targetDir dynlibTargetDir hiTargetDir builtDir _pkg lib clbi = do
-- copy .hi files over:
whenVanilla $ copyModuleFiles "hi"
whenProf $ copyModuleFiles "p_hi"
Expand Down Expand Up @@ -1151,7 +1152,7 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do

copyModuleFiles ext =
findModuleFiles [builtDir] [ext] (libModules lib)
>>= installOrdinaryFiles verbosity targetDir
>>= installOrdinaryFiles verbosity hiTargetDir

cid = compilerId (compiler lbi)
libName = componentUnitId clbi
Expand Down
6 changes: 4 additions & 2 deletions Cabal/Distribution/Simple/Install.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ install pkg_descr lbi flags = do
installDirs@(InstallDirs {
bindir = binPref,
libdir = libPref,
hidir = hiPref,
-- dynlibdir = dynlibPref, --see TODO below
datadir = dataPref,
docdir = docPref,
Expand Down Expand Up @@ -114,8 +115,9 @@ install pkg_descr lbi flags = do
| lfile <- lfiles ]

let buildPref = buildDir lbi
when (hasLibs pkg_descr) $
when (hasLibs pkg_descr) $ do
notice verbosity ("Installing library in " ++ libPref)
notice verbosity ("Installing library interface files in " ++ hiPref)
when (hasExes pkg_descr) $ do
notice verbosity ("Installing executable(s) in " ++ binPref)
inPath <- isInSearchPath binPref
Expand All @@ -130,7 +132,7 @@ install pkg_descr lbi flags = do

withLibLBI pkg_descr lbi $
case compilerFlavor (compiler lbi) of
GHC -> GHC.installLib verbosity lbi libPref dynlibPref buildPref pkg_descr
GHC -> GHC.installLib verbosity lbi libPref dynlibPref hiPref buildPref pkg_descr
GHCJS -> GHCJS.installLib verbosity lbi libPref dynlibPref buildPref pkg_descr
LHC -> LHC.installLib verbosity lbi libPref dynlibPref buildPref pkg_descr
JHC -> JHC.installLib verbosity lbi libPref dynlibPref buildPref pkg_descr
Expand Down
17 changes: 16 additions & 1 deletion Cabal/Distribution/Simple/InstallDirs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ data InstallDirs dir = InstallDirs {
includedir :: dir,
datadir :: dir,
datasubdir :: dir,
hidir :: dir,
docdir :: dir,
mandir :: dir,
htmldir :: dir,
Expand Down Expand Up @@ -116,6 +117,7 @@ combineInstallDirs combine a b = InstallDirs {
includedir = includedir a `combine` includedir b,
datadir = datadir a `combine` datadir b,
datasubdir = datasubdir a `combine` datasubdir b,
hidir = hidir a `combine` hidir b,
docdir = docdir a `combine` docdir b,
mandir = mandir a `combine` mandir b,
htmldir = htmldir a `combine` htmldir b,
Expand Down Expand Up @@ -181,7 +183,10 @@ defaultInstallDirs comp userInstall _hasLibs = do
JHC -> "$compiler"
LHC -> "$compiler"
UHC -> "$pkgid"
_other -> "$abi" </> "$libname",
_other -> case buildOS of
OSX -> "$abi" -- OSX libs go into a single directory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a link to that GHC trac ticket.

Copy link
Contributor

@bgamari bgamari Oct 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any particular reason to make this conditional on the operating system?

Placing dynamic libraries in per-package directories is actually a rather severe performance problem in general since the dynamic linker (on Linux at least) performs a linear scan through RPATH entries when looking for each library. For this reason just running ghc --help on Linux performs over 750 open system calls. This was first documented in GHC #11587 and the obvious solution is to move all dynamic libraries into a single directory, just as you've done here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was needed to fix OS X given time/manpower constraints. I, however, didn't know whether doing it for all operating systems was something all involved parties could agree on. If you, as GHC maintainer, are saying to do it for all operating systems, and Cabal maintainers agree, then it is an easy fix/patch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it makes sense if it improves start-up performance.

-- See: https://ghc.haskell.org/trac/ghc/ticket/12479
_otherOS -> "$abi" </> "$libname",
dynlibdir = "$libdir",
libexecdir = case buildOS of
Windows -> "$prefix" </> "$libname"
Expand All @@ -191,6 +196,11 @@ defaultInstallDirs comp userInstall _hasLibs = do
Windows -> "$prefix"
_other -> "$prefix" </> "share",
datasubdir = "$abi" </> "$pkgid",
hidir = "$libdir" </> case comp of
JHC -> "$compiler"
LHC -> "$compiler"
UHC -> "$pkgid"
_other -> "$abi" </> "$libname",
docdir = "$datadir" </> "doc" </> "$abi" </> "$pkgid",
mandir = "$datadir" </> "man",
htmldir = "$docdir" </> "html",
Expand Down Expand Up @@ -228,6 +238,7 @@ substituteInstallDirTemplates env dirs = dirs'
includedir = subst includedir prefixBinLibVars,
datadir = subst datadir prefixBinLibVars,
datasubdir = subst datasubdir [],
hidir = subst hidir prefixBinLibVars,
docdir = subst docdir prefixBinLibDataVars,
mandir = subst mandir (prefixBinLibDataVars ++ [docdirVar]),
htmldir = subst htmldir (prefixBinLibDataVars ++ [docdirVar]),
Expand Down Expand Up @@ -333,6 +344,7 @@ data PathTemplateVariable =
| LibsubdirVar -- ^ The @$libsubdir@ path variable
| DatadirVar -- ^ The @$datadir@ path variable
| DatasubdirVar -- ^ The @$datasubdir@ path variable
| HidirVar -- ^ The @$hidir@ path variable
| DocdirVar -- ^ The @$docdir@ path variable
| HtmldirVar -- ^ The @$htmldir@ path variable
| PkgNameVar -- ^ The @$pkg@ package name path variable
Expand Down Expand Up @@ -428,6 +440,7 @@ installDirsTemplateEnv dirs =
,(LibsubdirVar, libsubdir dirs)
,(DatadirVar, datadir dirs)
,(DatasubdirVar, datasubdir dirs)
,(HidirVar, hidir dirs)
,(DocdirVar, docdir dirs)
,(HtmldirVar, htmldir dirs)
]
Expand All @@ -450,6 +463,7 @@ instance Show PathTemplateVariable where
show LibsubdirVar = "libsubdir"
show DatadirVar = "datadir"
show DatasubdirVar = "datasubdir"
show HidirVar = "hidir"
show DocdirVar = "docdir"
show HtmldirVar = "htmldir"
show PkgNameVar = "pkg"
Expand Down Expand Up @@ -478,6 +492,7 @@ instance Read PathTemplateVariable where
,("libsubdir", LibsubdirVar)
,("datadir", DatadirVar)
,("datasubdir", DatasubdirVar)
,("hidir", HidirVar)
,("docdir", DocdirVar)
,("htmldir", HtmldirVar)
,("pkgid", PkgIdVar)
Expand Down
3 changes: 2 additions & 1 deletion Cabal/Distribution/Simple/Register.hs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi
IPI.exposedModules = componentExposedModules clbi,
IPI.hiddenModules = otherModules bi,
IPI.trusted = IPI.trusted IPI.emptyInstalledPackageInfo,
IPI.importDirs = [ libdir installDirs | hasModules ],
IPI.importDirs = [ hidir installDirs | hasModules ],
-- Note. the libsubdir and datasubdir templates have already been expanded
-- into libdir and datadir.
IPI.libraryDirs = if hasLibrary
Expand Down Expand Up @@ -378,6 +378,7 @@ inplaceInstalledPackageInfo inplaceDir distPref pkg abi_hash lib lbi clbi =
(absoluteInstallDirs pkg lbi NoCopyDest) {
libdir = inplaceDir </> libTargetDir,
datadir = inplaceDir </> dataDir pkg,
hidir = inplaceDir </> libTargetDir,
docdir = inplaceDocdir,
htmldir = inplaceHtmldir,
haddockdir = inplaceHtmldir
Expand Down
5 changes: 5 additions & 0 deletions Cabal/Distribution/Simple/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,11 @@ installDirsOptions =
datasubdir (\v flags -> flags { datasubdir = v })
installDirArg

, option "" ["hidir"]
"installation directory for library interface files"
hidir (\v flags -> flags { hidir = v })
installDirArg

, option "" ["docdir"]
"installation directory for documentation"
docdir (\v flags -> flags { docdir = v })
Expand Down
1 change: 1 addition & 0 deletions Cabal/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
extra-doc-files field is present (#3825).
* Fixed an incorrect invocation of GetShortPathName that was
causing build failures on Windows (#3649).
* Add '--hidir' option to indicate the location of interface files (#3955)

1.24.0.1 Ryan Thomas <ryan@ryant.org> May 2016
* Linker flags are now set correctly on GHC >= 7.8 (#3443).
Expand Down
4 changes: 3 additions & 1 deletion Cabal/doc/developing-packages.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -1952,6 +1952,7 @@ version :: Version

getBinDir :: IO FilePath
getLibDir :: IO FilePath
getHiDir :: IO FilePath
getDataDir :: IO FilePath
getLibexecDir :: IO FilePath
getSysconfDir :: IO FilePath
Expand Down Expand Up @@ -2185,7 +2186,7 @@ a few options:
`unregister`, `clean`, `dist` and `docs`. Some options to commands
are passed through as follows:

* The `--with-hc-pkg`, `--prefix`, `--bindir`, `--libdir`, `--datadir`,
* The `--with-hc-pkg`, `--prefix`, `--bindir`, `--libdir`, `--hidir`, `--datadir`,
`--libexecdir` and `--sysconfdir` options to the `configure` command are
passed on to the `configure` script. In addition the value of the
`--with-compiler` option is passed in a `--with-hc` option and all
Expand All @@ -2201,6 +2202,7 @@ a few options:
$(MAKE) install prefix=$(destdir)/$(prefix) \
bindir=$(destdir)/$(bindir) \
libdir=$(destdir)/$(libdir) \
hidir=$(destdir)/$(hidir) \
datadir=$(destdir)/$(datadir) \
libexecdir=$(destdir)/$(libexecdir) \
sysconfdir=$(destdir)/$(sysconfdir) \
Expand Down
18 changes: 16 additions & 2 deletions Cabal/doc/installing-packages.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ If a user-supplied `configure` script is run (see the section on
[system-dependent
parameters](developing-packages.html#system-dependent-parameters) or on
[complex packages](developing-packages.html#more-complex-packages)), it
is passed the `--with-hc-pkg`, `--prefix`, `--bindir`, `--libdir`,
is passed the `--with-hc-pkg`, `--prefix`, `--bindir`, `--libdir`, `--hidir`,
`--datadir`, `--libexecdir` and `--sysconfdir` options. In addition the
value of the `--with-compiler` option is passed in a `--with-hc` option
and all options specified with `--configure-option=` are passed on.
Expand Down Expand Up @@ -498,6 +498,16 @@ package:
variables: `$prefix`, `$bindir`, `$pkgid`, `$pkg`, `$version`,
`$compiler`, `$os`, `$arch`, `$abi`, `$abitag`

`--hidir=`_dir_
: Interfaces of libraries are installed here.

By default, this is the same as `$libdir/$libsubdir`; except on OS X, where
`$libsubdir` is set to `$abi`, but this setting is `$libdir/$abi/$libname`.

In the simple build system, _dir_ may contain the following path
variables: `$prefix`, `$bindir`, `$libdir`, `$libsubdir`, `$pkgid`,
`$pkg`, `$version`, `$compiler`, `$os`, `$arch`, `$abi`, `$abitag`

`--libexecdir=`_dir_
: Executables that are not expected to be invoked directly by the user
are installed here.
Expand Down Expand Up @@ -599,6 +609,9 @@ independence](#prefix-independence)).
`$datasubdir`
: As above but for `--datasubdir`

`$hidir`
: As above but for `--hidir`

`$docdir`
: As above but for `--docdir`

Expand Down Expand Up @@ -647,6 +660,7 @@ Option Windows Default
`--datadir` (executable) `$prefix` `$prefix/share`
`--datadir` (library) `C:\Program Files\Haskell` `$prefix/share`
`--datasubdir` `$pkgid` `$pkgid`
`--hidir` `$libdir\$abi\$libname` `$libdir/lib/$abi/$libname`
`--docdir` `$prefix\doc\$pkgid` `$datadir/doc/$pkgid`
`--sysconfdir` `$prefix\etc` `$prefix/etc`
`--htmldir` `$docdir\html` `$docdir/html`
Expand All @@ -666,7 +680,7 @@ install-time, rather than having to bake the path into the binary when it is
built.

In order to achieve this, we require that for an executable on Windows,
all of `$bindir`, `$libdir`, `$datadir` and `$libexecdir` begin with
all of `$bindir`, `$libdir`, `$hidir`, `$datadir` and `$libexecdir` begin with
`$prefix`. If this is not the case then the compiled executable will
have baked-in all absolute paths.

Expand Down
1 change: 1 addition & 0 deletions cabal-install/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,7 @@ storePackageInstallDirs CabalDirLayout{cabalStorePackageDirectory}
includedir = libdir </> "include"
datadir = prefix </> "share"
datasubdir = ""
hidir = prefix </> "lib"
docdir = datadir </> "doc"
mandir = datadir </> "man"
htmldir = docdir </> "html"
Expand Down
Loading