[commit: ghc] ghc-7.8: Include EXTRA_LD_OPTS (amongst other things) when linking programs (eafe20d)

git at git.haskell.org git at git.haskell.org
Mon Apr 14 13:53:21 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-7.8
Link       : http://ghc.haskell.org/trac/ghc/changeset/eafe20d77d9507f98278323432fbc5293ecef0e5/ghc

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

commit eafe20d77d9507f98278323432fbc5293ecef0e5
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Tue Mar 25 14:32:28 2014 +0000

    Include EXTRA_LD_OPTS (amongst other things) when linking programs
    
    One problem was that we weren't including $1_$2_DIST_LD_OPTS when
    linking a program, which looks to be accidental: it was being defined
    but not used anywhere.  This meant that setting $1_$2_EXTRA_LD_OPTS,
    for example, had no effect.
    
    This commit straightens out the handling of LD_OPTS to be consistent
    with the way we handle CC_OPTS and HC_OPTS.
    
    (cherry picked from commit 975e9cb8e7744a0750bb6c8763f628e05672643e)


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

eafe20d77d9507f98278323432fbc5293ecef0e5
 rules/build-prog.mk       |    4 ++--
 rules/distdir-way-opts.mk |   49 ++++++++++++++++++++++++++-------------------
 2 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/rules/build-prog.mk b/rules/build-prog.mk
index c6780d1..399369e 100644
--- a/rules/build-prog.mk
+++ b/rules/build-prog.mk
@@ -259,11 +259,11 @@ $1/$2/build/tmp/$$($1_$2_PROG).dll : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$(
 else
 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_$$($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))
+	$$(call cmd,$1_$2_HC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_HC_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))
 
 else
 $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_CC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_CC_OPTS) $$(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) $$($1_$2_$$($1_$2_PROGRAM_WAY)_EXTRA_CC_OPTS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
+	$$(call cmd,$1_$2_CC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_CC_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_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) $$($1_$2_$$($1_$2_PROGRAM_WAY)_EXTRA_CC_OPTS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
 endif
 endif
 
diff --git a/rules/distdir-way-opts.mk b/rules/distdir-way-opts.mk
index 8c0377e..93bc60b 100644
--- a/rules/distdir-way-opts.mk
+++ b/rules/distdir-way-opts.mk
@@ -131,20 +131,6 @@ endif
 endif
 endif
 
-ifeq "$3" "dyn"
-ifneq "$4" "0"
-ifeq "$$(TargetElf)" "YES"
-$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 += \
-    -fno-use-rpaths \
-    $$(foreach d,$$($1_$2_TRANSITIVE_DEPS),-optl-Wl$$(comma)-rpath -optl-Wl$$(comma)'@loader_path/../$$d')
-endif
-endif
-endif
-
 $1_$2_$3_ALL_CC_OPTS = \
  $$(WAY_$3_CC_OPTS) \
  $$($1_$2_DIST_GCC_CC_OPTS) \
@@ -154,13 +140,20 @@ $1_$2_$3_ALL_CC_OPTS = \
  $$(EXTRA_CC_OPTS)
 
 $1_$2_$3_GHC_CC_OPTS = \
- $$(addprefix -optc, \
-     $$(WAY_$3_CC_OPTS) \
-     $$($1_$2_DIST_CC_OPTS) \
-     $$($1_$2_$3_CC_OPTS) \
-     $$($$(basename $$<)_CC_OPTS) \
-     $$($1_$2_EXTRA_CC_OPTS) \
-     $$(EXTRA_CC_OPTS)) \
+ $$(addprefix -optc, $$($1_$2_$3_ALL_CC_OPTS)) \
+ $$($1_$2_$3_MOST_HC_OPTS)
+
+# Options for passing to plain ld
+$1_$2_$3_ALL_LD_OPTS = \
+ $$(WAY_$3_LD_OPTS) \
+ $$($1_$2_DIST_LD_OPTS) \
+ $$($1_$2_$3_LD_OPTS) \
+ $$($1_$2_EXTRA_LD_OPTS) \
+ $$(EXTRA_LD_OPTS)
+
+# Options for passing to GHC when we use it for linking
+$1_$2_$3_GHC_LD_OPTS = \
+ $$(addprefix -optl, $$($1_$2_$3_ALL_LD_OPTS)) \
  $$($1_$2_$3_MOST_HC_OPTS)
 
 $1_$2_$3_ALL_AS_OPTS = \
@@ -172,5 +165,19 @@ $1_$2_$3_ALL_AS_OPTS = \
  $$($1_$2_$3_AS_OPTS) \
  $$(EXTRA_AS_OPTS)
 
+ifeq "$3" "dyn"
+ifneq "$4" "0"
+ifeq "$$(TargetElf)" "YES"
+$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 += \
+    -fno-use-rpaths \
+    $$(foreach d,$$($1_$2_TRANSITIVE_DEPS),-optl-Wl$$(comma)-rpath -optl-Wl$$(comma)'@loader_path/../$$d')
+endif
+endif
+endif
+
 endef
 



More information about the ghc-commits mailing list