[commit: ghc] master: Add a -rpath entry for the RTS library, so that it can find libffi (9d9d09d)

Ian Lynagh <[email protected]> Fri, 04 Jan 2013 11:44:49 -0800
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/9d9d09defda3dfc2362785608110e56d1fc1f3b2

>---------------------------------------------------------------

commit 9d9d09defda3dfc2362785608110e56d1fc1f3b2
Author: Ian Lynagh <[email protected]>
Date:   Fri Jan 4 18:43:19 2013 +0000

    Add a -rpath entry for the RTS library, so that it can find libffi
    
    This fixes dynamic library resolution when --enable-new-dtags is used
    (#7062).
    
    When --enable-new-dtags is used when linking an executable, a RUNPATH as
    well as RPATH is set. The linker then ignores RPATH, and RUNPATH is only
    used for directly (not transitively) needed libraries. As the program
    doesn't directly need libffi, it isn't found.

>---------------------------------------------------------------

 rts/ghc.mk |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/rts/ghc.mk b/rts/ghc.mk
index d605dff..1119a88 100644
--- a/rts/ghc.mk
+++ b/rts/ghc.mk
@@ -196,6 +196,10 @@ $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/libs.depend rts/dist/b
 else
 ifneq "$(UseSystemLibFFI)" "YES"
 LIBFFI_LIBS = -Lrts/dist/build -lffi 
+ifeq "$$(TargetOS_CPP)" "linux"
+LIBFFI_LIBS += -optl-Wl,-rpath -optl-Wl,'$$$$ORIGIN'
+endif
+
 else
 # flags will be taken care of in rts/libs.depend
 LIBFFI_LIBS =