Tim Cuthbertson | 28 May 2012 14:36
Favicon
Gravatar

relocatable packages: GHC_PACKAGE_PATH and package.conf

Hi all,

I'm trying to build a relocatable package using cabal, and running
into some difficulties.
I've created / used the following script to attempt to create a
relocatable package:
https://github.com/gfxmonk/0compile-cabal-build/blob/2cf4a08b146333d9292f6f8fd38431dd5c5c80f1/cabal-build

When this is done I have something that looks like it should work, and
has an inline package.conf. But when I run the following:

-----------------------------------------------
$ export GHC_PACKAGE_PATH="/home/tim/dev/haskell/third-party/haskell-ansi-terminal/haskell-ansi-terminal-linux-x86_64/package.conf:"
$ ghc-pkg check
There are problems in package ansi-terminal-0.5.5:
 import-dirs: ${pkgroot}/lib is a relative path
 library-dirs: ${pkgroot}/lib is a relative path
 file System/Console/ANSI.hi is missing
 file System/Console/ANSI/Unix.hi is missing
 file System/Console/ANSI/Common.hi is missing
 cannot find libHSansi-terminal-0.5.5.a on library path

The following packages are broken, either because they have a problem
listed above, or because they depend on a broken package.
ansi-terminal-0.5.5
-----------------------------------------------

So it looks like:
 - I need to set more environment variabes so that ghc can find the
parts of the package (e.g libHSansi-terminal-0.5.5.a). Unfortunately,
(Continue reading)

Duncan Coutts | 28 May 2012 16:24

Re: relocatable packages: GHC_PACKAGE_PATH and package.conf

On 28 May 2012 05:36, Tim Cuthbertson <tim <at> gfxmonk.net> wrote:

>  - ghc doesn't seem to support ${pkgroot} prefixes. I thought it did,
> but I'm new to this so I may be misunderstanding where they can be
> used.

I thought it did too since I think I wrote the code for it. I don't
recall exactly what version it got into, it may well have been only
7.2+

> Additionally, the paths that come out of cabal build have the compiler
> name and version hard coded, e.g lib/packagename/ghc-7.0.4/*. Is there
> any way to configure how this path is constructed to get rid of the
> ghd-7.0.4 part?

By default, yes, cabal produces absolute packages. It does have
support for relocatable packages on some compiler/platform combos:

http://www.haskell.org/cabal/users-guide/installing-packages.html#prefix-independence

sadly ghc on unix is not one of them because we do not have a reliable
way to find the program location (needed to find data files etc).
Actually more specifically it's not easy and nobody has implemented
it, rather than it being impossible.

So at the moment you could work around it in specific cases by hacking
the package registration info before registering. Do something like:
cabal copy --destdir=...
cabal register --gen-pkg-config=blah.pkg
sed -i =e '...' blah.pkg
(Continue reading)

Tim Cuthbertson | 29 May 2012 05:14
Favicon
Gravatar

Re: relocatable packages: GHC_PACKAGE_PATH and package.conf

On Tue, May 29, 2012 at 12:24 AM, Duncan Coutts
<duncan.coutts <at> googlemail.com> wrote:
> On 28 May 2012 05:36, Tim Cuthbertson <tim <at> gfxmonk.net> wrote:
>
>>  - ghc doesn't seem to support ${pkgroot} prefixes. I thought it did,
>> but I'm new to this so I may be misunderstanding where they can be
>> used.
>
> I thought it did too since I think I wrote the code for it. I don't
> recall exactly what version it got into, it may well have been only
> 7.2+

Ahh, right you are - I must have looked at the "reported" version
instead of "milestone" in the bug:

$ git name-rev --tags 40b6bd47cf00f025426746bbd7abdd0eda2a3afd
40b6bd47cf00f025426746bbd7abdd0eda2a3afd tags/ghc-7.2.1-release~397

I'll have to compile it myself, but that's much better than it simply
not working ;)

>> Additionally, the paths that come out of cabal build have the compiler
>> name and version hard coded, e.g lib/packagename/ghc-7.0.4/*. Is there
>> any way to configure how this path is constructed to get rid of the
>> ghd-7.0.4 part?
>
> By default, yes, cabal produces absolute packages. It does have
> support for relocatable packages on some compiler/platform combos:
>
> http://www.haskell.org/cabal/users-guide/installing-packages.html#prefix-independence
(Continue reading)


Gmane