[commit: ghc] master: Give dynamic libraries, as well as programs, RPATHs (7dd7008)

Ian Lynagh <[email protected]>
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/7dd7008f98c76024288899b8cea607141c91ada5

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

commit 7dd7008f98c76024288899b8cea607141c91ada5
Author: Ian Lynagh <[email protected]>
Date:   Thu Nov 8 21:46:46 2012 +0000

    Give dynamic libraries, as well as programs, RPATHs
    
    Based on a patch from markwright in #3072.

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

 rules/build-package-way.mk |    4 ++--
 rules/build-prog.mk        |   25 ++++++++++++-------------
 rules/distdir-way-opts.mk  |   12 ++++++++++++
 3 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk
index 7a028d5..60f4ecb 100644
--- a/rules/build-package-way.mk
+++ b/rules/build-package-way.mk
@@ -69,7 +69,7 @@ ifeq "$3" "dyn"
 # On windows we have to supply the extra libs this one links to when building it.
 ifeq "$$(HostOS_CPP)" "mingw32"
 $$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS)
-	$$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) $$($1_$2_$3_ALL_OBJS) \
+	$$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) $$($1_$2_$3_GHC_LD_OPTS) $$($1_$2_$3_ALL_OBJS) \
          -shared -dynamic -dynload deploy \
 	 $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES)) \
          -no-auto-link-packages \
@@ -79,7 +79,7 @@ $$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS)
 
 else
 $$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS)
-	$$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) $$($1_$2_$3_ALL_OBJS) \
+	$$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) $$($1_$2_$3_GHC_LD_OPTS) $$($1_$2_$3_ALL_OBJS) \
          -shared -dynamic -dynload deploy \
 	 $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES)) $$(addprefix -L,$$($1_$2_EXTRA_LIBDIRS)) \
          -no-auto-link-packages \
diff --git a/rules/build-prog.mk b/rules/build-prog.mk
index 6ce4d6f..2c1836a 100644
--- a/rules/build-prog.mk
+++ b/rules/build-prog.mk
@@ -170,20 +170,19 @@ ifeq "$$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS)" ""
 # We don't want to link the GHC RTS into C-only programs. There's no
 # point, and it confuses the test that all GHC-compiled programs
 # were compiled with the right GHC.
-$1_$2_GHC_LD_OPTS = -no-auto-link-packages -no-hs-main
+$1_$2_$$($1_$2_PROGRAM_WAY)_GHC_LD_OPTS += -no-auto-link-packages -no-hs-main
 endif
 
-ifneq "$3" "0"
-ifeq "$$(DYNAMIC_BY_DEFAULT)" "YES"
-ifeq "$$(TargetOS_CPP)" "linux"
-$1_$2_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)" "darwin"
-$1_$2_GHC_LD_OPTS = -optl-Wl,-headerpad_max_install_names
-endif
-endif
-endif
+# XXX
+# ifneq "$3" "0"
+# ifeq "$$(TargetOS_CPP)" "linux"
+# $1_$2_dyn_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)" "darwin"
+# $1_$2_dyn_GHC_LD_OPTS += -optl-Wl,-headerpad_max_install_names
+# endif
+# endif
 
 ifneq "$$(BINDIST)" "YES"
 # The quadrupled $'s here are because the _<way>_LIB variables aren't
@@ -199,7 +198,7 @@ $1/$2/build/tmp/$$($1_$2_PROG) : \
 
 ifeq "$$($1_$2_LINK_WITH_GCC)" "NO"
 $1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/.
-	$$(call cmd,$1_$2_HC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_HC_OPTS) $$(LD_OPTS) $$($1_$2_GHC_LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
+	$$(call cmd,$1_$2_HC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_HC_OPTS) $$(LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_GHC_LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
 ifeq "$$(TargetOS_CPP)" "darwin"
 ifneq "$3" "0"
 ifeq "$$($1_$2_PROGRAM_WAY)" "dyn"
diff --git a/rules/distdir-way-opts.mk b/rules/distdir-way-opts.mk
index ed2a4d0..4d27bbf 100644
--- a/rules/distdir-way-opts.mk
+++ b/rules/distdir-way-opts.mk
@@ -172,6 +172,18 @@ $1_$2_DIST_LD_OPTS = \
  $$(foreach opt,$$($1_$2_DEP_EXTRA_LIBS),-l$$(opt)) \
  $$($1_$2_DEP_LD_OPTS)
 
+ifeq "$3" "dyn"
+ifneq "$4" "0"
+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)" "darwin"
+$1_$2_$3_GHC_LD_OPTS += -optl-Wl,-headerpad_max_install_names
+endif
+endif
+endif
+
 # c.f. Cabal's Distribution.Simple.PreProcess.ppHsc2hs
 # We use '' around cflags and lflags to handle paths with backslashes in
 # on Windows
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.