[GHC] #7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------------+------------------------------------------ Reporter: igloo | Owner: Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ In #7806, kazu-yamamoto reported that on FreeBSD without a system libffi: GHC can be built: {{{ % make maintainer-clean % perl boot % ./configure --prefix=/ghc-head \ --with-iconv-includes=/usr/local/include \ --with-iconv-libraries=/usr/local/lib \ --with-gmp-includes=/usr/local/include \ --with-gmp-libraries=/usr/local/lib \ --with-gcc=/usr/local/bin/gcc47 \ --with-gcc-4.2=/usr/local/bin/gcc47 % gmake -j10 }}} But installation fails: {{{ % gmake install Installing library in /ghc-head/lib/ghc-7.7.20130323/haskell2010-1.1.1.0 "/ghc-head/lib/ghc-7.7.20130323/bin/ghc-pkg" --force --global-package-db "/ghc-head/lib/ghc-7.7.20130323/package.conf.d" update rts/package.conf.install Shared object "libffi.so.6" not found, required by "libHSrts- ghc7.7.20130323.so" gmake[1]: *** [install_packages] Error 1 gmake: *** [install] Error 2 }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------------+------------------------------------------ Reporter: igloo | Owner: pgj Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Keywords: | Os: FreeBSD Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by igloo): * owner: => pgj * os: Unknown/Multiple => FreeBSD Comment: pgj, would you be able to take a look at this please? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------------+------------------------------------------ Reporter: igloo | Owner: pgj Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Keywords: | Os: FreeBSD Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by pgj): Sure, I am hoping fix this in the coming days. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------------+------------------------------------------ Reporter: igloo | Owner: pgj Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Keywords: | Os: FreeBSD Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by kazu-yamamoto): * cc: kazu@… (added) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------------+------------------------------------------ Reporter: igloo | Owner: pgj Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Keywords: | Os: FreeBSD Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by PHO): * cc: pho@… (added) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------------+------------------------------------------ Reporter: igloo | Owner: pgj Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Keywords: | Os: FreeBSD Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by pgj): Well, regarding `libffi` I believe the following patch could solve the situation for you (please test): {{{ diff --git a/rts/ghc.mk b/rts/ghc.mk index b7651b0..a1e771e 100644 --- a/rts/ghc.mk +++ b/rts/ghc.mk @@ -186,7 +186,7 @@ else ifneq "$$(UseSystemLibFFI)" "YES" LIBFFI_LIBS = -Lrts/dist/build -lffi ifeq "$$(TargetElf)" "YES" -LIBFFI_LIBS += -optl-Wl,-rpath -optl-Wl,'$$$$ORIGIN' +LIBFFI_LIBS += -optl-Wl,-rpath -optl-Wl,'$$$$ORIGIN' -optl-Wl,-zorigin endif }}} On FreeBSD, one needs to invoke `ld(1)` with `-z origin` in order to enable resolution of `$ORIGIN` in `RPATH`. However, I guess we shall also have to face a more generic problem here: dynamic library paths are not linked as relative on FreeBSD, because `ghc- pkg` is not linked with other dependent dynamic libraries in its `RPATH`. I tried to use the Linux approach, i.e. enabled linking with relative paths in `rules/distdir-way-opts.mk` by applying the following (trivial) patch: {{{ diff --git a/rules/distdir-way-opts.mk b/rules/distdir-way-opts.mk index 872e527..fd9f5e5 100644 --- a/rules/distdir-way-opts.mk +++ b/rules/distdir-way-opts.mk @@ -129,6 +129,11 @@ ifeq "$$(TargetOS_CPP)" "linux" $1_$2_$3_GHC_LD_OPTS += \ -fno-use-rpaths \ $$(foreach d,$$($1_$2_TRANSITIVE_DEPS),-optl-Wl$$(comma)-rpath -optl- Wl$$(comma)'$$$$ORIGIN/../$$d') +else ifeq "$$(TargetOS_CPP)" "freebsd" +$1_$2_$3_GHC_LD_OPTS += \ + -fno-use-rpaths \ + $$(foreach d,$$($1_$2_TRANSITIVE_DEPS),-optl-Wl$$(comma)-rpath -optl- Wl$$(comma)'$$$$ORIGIN/../$$d') \ + -optl-Wl,-zorigin else ifeq "$$(TargetOS_CPP)" "darwin" $1_$2_$3_GHC_LD_OPTS += -optl-Wl,-headerpad_max_install_names endif }}} Unfortunately the chances are high that there is `rtld(1)` bug in handling `$ORIGIN` substitutions and can only work with path sizes lesser than 1024. When I modified `rtld(1)` to work with larger path sizes, it worked, but I am now waiting for an official fix. The builder clients work because they have the absolute paths embedded inside and installing them to a different location does not make any difference in that case. But when somebody tries to install the vanilla binary tarball they generate it will fail in a similar way. Ian, do you have any recommendations how to work this problem around? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------------+------------------------------------------ Reporter: igloo | Owner: pgj Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Keywords: | Os: FreeBSD Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by kazu-yamamoto): The build and installation works well with your first patch (only). But the installed GHC refers to the dynamic libraries in the build directory. So, after "gmake maintainer-clean", the installed GHC cannot find necessary dynamic libraries. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------------+------------------------------------------ Reporter: igloo | Owner: pgj Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Keywords: | Os: FreeBSD Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by pgj): Replying to [comment:6 kazu-yamamoto]:
The build and installation works well with your first patch (only).
But the installed GHC refers to the dynamic libraries in the build
Great! directory.
So, after "gmake maintainer-clean", the installed GHC cannot find necessary dynamic libraries.
Yes, as I noted in my previous comment, this is because of a bug in `rtld(1)`. If you want to see this working, you can experiment with a [http://people.freebsd.org/~pgj/patches/2013/04/15/rtld-releng91.fix.diff fix] (written by Kostik Belousov). Download the diff, and rebuild your `ld-elf.so.1` from the base system source code. This should be under `/usr/src/libexec/rtld-elf`, where you should just apply the patch and reinstall the dynamic loader by issuing the following commands below. {{{ # make # make install }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------------+------------------------------------------ Reporter: igloo | Owner: pgj Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Keywords: | Os: FreeBSD Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by kazu-yamamoto): Please merge these patches. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------------+------------------------------------------ Reporter: igloo | Owner: pgj Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Keywords: | Os: FreeBSD Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by pgj): Replying to [comment:8 kazu-yamamoto]:
Please merge these patches.
Note that due to the referenced bug in the `rtld(1)`, they can only work on a recent version of FreeBSD-CURRENT at the moment. I suppose the rtld(1) fix will be merged back to 8-STABLE and 9-STABLE in a week or so, but 8.4-RELEASE may not contain this fix, and we will have to wait for another couple of weeks for 9.2-RELEASE to "officially" have it. On the other hand, there should be some support for older release as well, i.e. for the releases (8.x, pre 9.2) who still has this bug in handling `$ORIGIN`. I shall consult Ian on the possible scenarios, but definitely want to merge this patches as soon as possible. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------------+------------------------------------------ Reporter: igloo | Owner: pgj Type: bug | Status: patch Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Keywords: | Os: FreeBSD Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by igloo): * status: new => patch -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found
---------------------------------+------------------------------------------
Reporter: igloo | Owner: pgj
Type: bug | Status: patch
Priority: high | Milestone: 7.8.1
Component: Build System | Version: 7.6.2
Keywords: | Os: FreeBSD
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Comment(by ian@…):
commit ce1094ea87e58f5172f623c61cbb250a3194e0b0
{{{
Author: Ian Lynagh

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found
---------------------------------+------------------------------------------
Reporter: igloo | Owner: pgj
Type: bug | Status: patch
Priority: high | Milestone: 7.8.1
Component: Build System | Version: 7.6.2
Keywords: | Os: FreeBSD
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Comment(by ian@…):
commit 9843083601adb7db03844aecd9a855b0d06609a7
{{{
Author: Ian Lynagh

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------+------------------------------------------------ Reporter: igloo | Owner: Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Resolution: | Keywords: Os: FreeBSD | Architecture: Unknown/Multiple Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ Changes (by igloo): * owner: pgj => * status: patch => new Comment: Thanks, I've applied the patches. Do the nightly builders have a patched ld? If so, I guess we should close the ticket now: I'm not sure what else we can do but wait for FreeBSD to fix the bug. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------+------------------------------------------------ Reporter: igloo | Owner: Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Resolution: | Keywords: Os: FreeBSD | Architecture: Unknown/Multiple Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ Comment(by pgj): Replying to [comment:13 igloo]:
Thanks, I've applied the patches.
Thanks!
Do the nightly builders have a patched ld?
Currently they do not have, but I can patch the `rtld(1)` any time. My problem was rather that the users who may want to use produced snapshots will not have this patch installed. But perhaps I could add a note on this to somewhere in the wiki.
If so, I guess we should close the ticket now: I'm not sure what else we can do but wait for FreeBSD to fix the bug.
I can understand that you do not want to clutter the upstream sources with such corner cases -- I think I will be able to handle this in the corresponding port, I was just hoping that we could have a flag to keep it working without relying on `$ORIGIN`. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------+------------------------------------------------ Reporter: igloo | Owner: Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Resolution: | Keywords: Os: FreeBSD | Architecture: Unknown/Multiple Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ Comment(by igloo): Ah, you need the patch when linking against the libraries, rather than when creating the libraries? What other fix did you have in mind? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------+------------------------------------------------ Reporter: igloo | Owner: pgj Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Resolution: | Keywords: Os: FreeBSD | Architecture: Unknown/Multiple Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ Changes (by pgj): * owner: => pgj Comment: Replying to [comment:15 igloo]:
What other fix did you have in mind?
Okay, I think I have solved it: Disable `DYNAMIC_GHC_PROGRAMS` for FreeBSD by default. Later I can override this in the Ports Collection for the FreeBSD releases that contain the aforementioned `rtld(1)` fix. {{{ diff --git a/mk/config.mk.in b/mk/config.mk.in index 55f5756..af70215 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -134,6 +134,9 @@ DYNAMIC_TOO = YES ifeq "$(TargetOS_CPP)" "mingw32" # This doesn't work on Windows yet DYNAMIC_GHC_PROGRAMS = NO +# This does not work on FreeBSD yet as well +else ifeq "$(TargetOS_CPP)" "freebsd" +DYNAMIC_GHC_PROGRAMS = NO else DYNAMIC_GHC_PROGRAMS = YES endif }}} If there is no objection, I push this fix later today and close the ticket. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------+------------------------------------------------ Reporter: igloo | Owner: pgj Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Resolution: | Keywords: Os: FreeBSD | Architecture: Unknown/Multiple Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ Comment(by igloo): That'll be OK for 7.8. In 7.9 ghci won't work with `DYNAMIC_GHC_PROGRAMS=NO`, but that gives more than a year for the rtld patches to trickle down. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found
---------------------------+------------------------------------------------
Reporter: igloo | Owner: pgj
Type: bug | Status: new
Priority: high | Milestone: 7.8.1
Component: Build System | Version: 7.6.2
Resolution: | Keywords:
Os: FreeBSD | Architecture: Unknown/Multiple
Failure: None/Unknown | Difficulty: Unknown
Testcase: | Blockedby:
Blocking: | Related:
---------------------------+------------------------------------------------
Comment(by pali.gabor@…):
commit 8ab3cc1b878ac5915295e6f31ac9b592a4bde8c6
{{{
Author: Gabor Pali

That'll be OK for 7.8. In 7.9 ghci won't work with `DYNAMIC_GHC_PROGRAMS=NO`, but that gives more than a year for the rtld
#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------+------------------------------------------------ Reporter: igloo | Owner: pgj Type: bug | Status: closed Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Resolution: fixed | Keywords: Os: FreeBSD | Architecture: Unknown/Multiple Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ Changes (by pgj): * status: new => closed * resolution: => fixed Comment: Replying to [comment:17 igloo]: patches to trickle down. Okay, now closing the ticket. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7819: FreeBSD without system libffi: Shared object "libffi.so.6" not found ---------------------------+------------------------------------------------ Reporter: igloo | Owner: pgj Type: bug | Status: closed Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.6.2 Resolution: fixed | Keywords: Os: FreeBSD | Architecture: Unknown/Multiple Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ Comment(by kazu-yamamoto): OK. I confirmed that ghc is now statically linked to GHC libraries. Thank you! -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7819#comment:20 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC