|
# Shared Libraries: distribution and build-system issues
|
|
# Shared Libraries: distribution and build-system issues
|
|
|
|
|
|
|
|
|
|
|
|
This page is for discussing and documenting our strategy for
|
|
|
|
|
|
|
|
- How shared libraries are found
|
|
|
|
- How the build system works
|
|
|
|
- How distributions (of GHC and programs built by GHC) work
|
|
|
|
- Issues that affect Cabal
|
|
|
|
|
|
|
|
## Goals/Scenarios
|
|
|
|
|
|
|
|
|
|
|
|
First of all, we take it as a given that a normal GHC installation will be a good citizen on its host platform: shared libraries will go in the standard locations, and we'll use the system's normal method for finding them at link time and runtime. Windows is an exception: there is no standard location for installing shared libraries on Windows.
|
|
|
|
|
|
|
|
|
|
|
|
So that we can support having multiple versions of GHC installed, shared libraries will have the GHC version number embedded, e.g. `libHSghc6.6.1-network-1.1.so`.
|
|
|
|
|
|
|
|
|
|
|
|
Here is what else we'd like to do:
|
|
|
|
|
|
|
|
1. Support installing GHC outside of the standard location (e.g. in a home directory), and build
|
|
|
|
binaries using that installation. Multiple such installations should be supported.
|
|
|
|
1. We need to build a distribution that supports choosing the install location at install time, for
|
|
|
|
use in (1).
|
|
|
|
1. Binaries that are built as part of the GHC build (e.g. stage2/ghc-inplace) need to run from
|
|
|
|
the build tree.
|
|
|
|
1. Cabal needs to build libraries that can be installed in the system location or elsewhere.
|
|
|
|
|
|
|
|
# Proposed strategies
|
|
|
|
|
|
|
|
## 1. Static linking
|
|
|
|
|
|
|
|
|
|
|
|
(1,2) Installations of GHC that are not in the standard locations use static linking and come with static libraries only.
|
|
|
|
|
|
|
|
|
|
|
|
(3) stage2/ghc-inplace is linked statically.
|
|
|
|
|
|
|
|
|
|
|
|
(4) Cabal packages installed outside the system locations are static only.
|
|
|
|
|
|
|
|
|
|
|
|
This is attractive, but there are some drawbacks:
|
|
|
|
|
|
|
|
- we still need to build a distribution that uses shared libs. Presumably we have to build both
|
|
|
|
shared and static libs then.
|
|
|
|
- the testsuite needs to build binaries against the shared libs for testing, without installing GHC.
|
|
|
|
- we want the GHC binary in a shared-library installation to be dynamically linked, not statically linked.
|
|
|
|
- if there are some static-only libraries on the system, then all packages must have static versions,
|
|
|
|
because dynamic linking is all-or-nothing in GHC.
|
|
|
|
- This approach doesn't address Windows
|
|
|
|
|
|
|
|
## 2. Dynamic linking
|
|
|
|
|
|
|
|
|
|
|
|
The first plan was this:
|
|
|
|
|
|
|
|
[ http://www.haskell.org/pipermail/glasgow-haskell-users/2007-June/012740.html](http://www.haskell.org/pipermail/glasgow-haskell-users/2007-June/012740.html)
|
|
|
|
|
|
|
|
|
|
|
|
It has since been pointed out that `LD_LIBRARY_PATH` overrides `-rpath` on some platforms (see below). This might cause some difficulties (or not?).
|
|
|
|
|
|
|
|
|
|
|
|
Assuming we can fix the locations of shared libraries at link time (eg. with -rpath), then:
|
|
|
|
|
|
|
|
1. Installations of GHC outside the system default location hardwire the locations of shared libraries
|
|
|
|
into the binaries they build. (hence such binaries cannot be distributed; this is a drawback)
|
|
|
|
1. Binaries in the distribution must not have rpaths. We should use wrapper scripts that set
|
|
|
|
`LD_LIBRARY_PATH` instead.
|
|
|
|
1. Binaries in the build tree need `LD_LIBRARY_PATH` wrappers.
|
|
|
|
1. A Cabal package may install a shared library outside the standard location, but when linking to
|
|
|
|
it we must do the equivalent of adding -rpath to point to its location.
|
|
|
|
|
|
|
|
|
|
|
|
ToDo: Windows?
|
|
|
|
|
|
|
|
## 3. libtool
|
|
|
|
|
|
|
|
|
|
|
|
ToDo: can someone explain how libtool works and how we can use it?
|
|
|
|
|
|
# Platform support for locating shared libraries
|
|
# Platform support for locating shared libraries
|
|
|
|
|
|
|
|
|
... | | ... | |