[GHC] #11587: Place shared objects in LIBDIR
GHC
ghc-devs at haskell.org
Wed Feb 17 23:57:11 UTC 2016
#11587: Place shared objects in LIBDIR
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 8.0.1
Component: Package system | Version: 7.10.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by chak):
* cc: trommler (removed)
* cc: Trommler, chak (added)
Comment:
I have wondered about this set up in the past. More precisely, I think
having the dynamic libraries for different packages in separate
directories with the interface files etc of the package makes a lot of
sense. I keeps the `$LIBDIR` tidy.
However, the dynamic linking set up does appear to be rather inefficient
and, at least on OS X, it makes relocating GHC distributions very hard. In
the Haskell for Mac build, I hence, post-process all executables and
dynamic libraries to optimise the linking process. As my ELF is a bit
rusty let me explain it in MACH-O terms. I am setting the `RPATH` in all
executables such that it points to `$LIBDIR` and I set the library name of
each dynamic library to include the package directory. For example, for
`base`, we might have `base_GDytRqRVSUX7zckgKqJjgw/libHSbase-4.8.1.0
-GDytRqRVSUX7zckgKqJjgw-ghc7.10.2.dylib`.
I also set `RPATH` to be relative to `@loader_PATH`, which gives me a
relocatable set of dynamic libraries and GHC executables.
So, for example, here is what `base` looks like
{{{
LC 03: LC_ID_DYLIB
@rpath/base_GDytRqRVSUX7zckgKqJjgw/libHSbase-4.8.1.0
-GDytRqRVSUX7zckgKqJjgw-ghc7.10.2.dylib
...
LC 12: LC_LOAD_DYLIB @rpath/integ_2aU3IZNMF9a7mQ0OzsZ0dS
/libHSinteger-gmp-1.0.0.0-2aU3IZNMF9a7mQ0OzsZ0dS-ghc7.10.2.dylib
LC 13: LC_LOAD_DYLIB @rpath/ghcpr_8TmvWUcS1U1IKHT0levwg3
/libHSghc-prim-0.4.0.0-8TmvWUcS1U1IKHT0levwg3-ghc7.10.2.dylib
...
LC 19: LC_RPATH @loader_path/..
}}}
This avoids the quadratic explosion of the search space, but still keeps
the dynamic libraries in the package directories (and `$LIBDIR` tidier).
This is definitely the better set up on OS X. Can't we do something
equivalent on Linux?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11587#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list