Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 411925 - =dev-lang/ghc-7.4.1 uses bundled libffi
Summary: =dev-lang/ghc-7.4.1 uses bundled libffi
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Haskell Language team
URL: http://hackage.haskell.org/trac/ghc/t...
Whiteboard:
Keywords:
Depends on:
Blocks: bundled-libs
  Show dependency tree
 
Reported: 2012-04-14 09:12 UTC by Sergei Trofimovich (RETIRED)
Modified: 2014-06-27 10:28 UTC (History)
10 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch v2 (gentoo411925a.patch,4.25 KB, patch)
2012-04-24 19:16 UTC, Martin von Gagern
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich (RETIRED) gentoo-dev 2012-04-14 09:12:18 UTC
Coupled with limitations of build system in leads to bug #411789
Comment 1 Martin von Gagern 2012-04-14 17:16:53 UTC
Also causes problems with portage-2.2 @preserved-libs: ghc will always depend on libffi.so.5, and @preserved-libs doesn't know that this will likely be satisfied by /usr/lib64/ghc-7.4.1/libffi.so.5, so it refuses to unmerge the preserved /usr/lib64/libffi.so.5.
Comment 2 Martin von Gagern 2012-04-24 19:16:06 UTC
Created attachment 309949 [details, diff]
Patch v2

The upstream ticket mentioned in the URL references a patch which apparently is used by both Debian and Fedora. That patch (let's call it v1) wasn't enough for me: the build complained about ffi.h not being found. Apparently other distros install that header in some global place, whereas Gentoo installs it into the strange location of /usr/lib64/libffi-3.0.11/include .

The best way to find that location is probably using pkg-config. So I added two more hunks to pass the output of "pkg-config --cflags-only-I libffi" to the relevant compiler invocations. I did so in a fairly minimalistic way, only affecting those command lines which need it. There might be a way to set this more easily for the whole build process, but as their build process is fairly non-standard, I didn't feel like searching for alternatives once I found one viable solution. I'm attaching the resulting patch, v2.

Note that the common approach of "ebuild prepare + patch + ebuild merge" won't work for ghc, as the unpack phase will change the timestamp of the WORKDIR, causing the second run to recreate the WORKDIR, replacing the patched tree. If you as a user want to apply the patch that way, touch the WORKDIR in between. As one alternative, you could copy the ebuild to an overlay. As another alternative, you could wait till the main portage tree receives a revbump with that patch (or some version of it) included. If devs were to add a call to epatch_user, such problems would be a lot simpler to address in the future.
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2012-04-24 19:40:06 UTC
The patch looks good. Thank you!

Pushed to overlay for now:
https://github.com/gentoo-haskell/gentoo-haskell/commit/2745ae0c699bab3bdf83fc2b3ba6903005ebc7b4

Does it also add libffi include path to generated
  /usr/lib/ghc-7.4.1/package.conf.d/builtin_rts.conf
?

I'm afraid failure to do so will render in nonworking stub generator
for unreg arches.
Comment 4 Martin von Gagern 2012-04-24 21:46:58 UTC
(In reply to comment #3)
> Does it also add libffi include path to generated builtin_rts.conf?

No. It does add ffi to extra-libs, but nothing for include-dirs. There is already a hunk adding that line, but transporting the required information from the build system into the text substitution for that file might be nontrivial.
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2012-04-27 18:20:02 UTC
OK. Pushed Martin's patch as is.

>*ghc-7.4.1-r1 (27 Apr 2012)
>
>  27 Apr 2012; Sergei Trofimovich <slyfox@gentoo.org>
>  +files/ghc-7.4.2-system-libffi.patch, +ghc-7.4.1-r1.ebuild:
>  Switched to using system's libffi. Thanks for the fix to Martin von Gagern
>  (bug #411925). Added new variable to override disabled parallel build:
>  'I_DEMAND_MY_CORES_LOADED' (Brave Hearts only).

Thank you, Martin!

I'll close the bug once:
- test on some unreg arches
- and add libffi/libgmp as backup libraries for binary ghc builds (only bootstrap binaries).
Comment 6 Sergei Trofimovich (RETIRED) gentoo-dev 2012-07-08 19:32:52 UTC
OK, the patch has a deficiency: rts.conf does not store libffi includepaths in it.

It leads to build breakage on unreg platforms.
Comment 7 Martin von Gagern 2012-07-08 20:17:10 UTC
As I don't have a good idea of what you mean by "unreg arches", I don't feel like I can contribute here. Can you improve on my patch on a system where you can test those improvements?
Comment 8 Sergei Trofimovich (RETIRED) gentoo-dev 2014-06-27 10:28:54 UTC
Initial fix was handled upstream:
https://ghc.haskell.org/trac/ghc/ticket/5743

Unregisterised (./configure --enable-unregisterised) arches were fixed in:
https://ghc.haskell.org/trac/ghc/ticket/8748