summaryrefslogtreecommitdiff
path: root/rules/distdir-way-opts.mk
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2014-03-25 14:32:28 +0000
committerSimon Marlow <marlowsd@gmail.com>2014-03-27 12:36:14 +0000
commit975e9cb8e7744a0750bb6c8763f628e05672643e (patch)
tree77f41a1779a1c303f79812d6b1dc3452e57ce476 /rules/distdir-way-opts.mk
parenta6f2c852d49313fa8acea2deb3741ab86c6ef995 (diff)
downloadhaskell-975e9cb8e7744a0750bb6c8763f628e05672643e.tar.gz
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.
Diffstat (limited to 'rules/distdir-way-opts.mk')
-rw-r--r--rules/distdir-way-opts.mk49
1 files changed, 28 insertions, 21 deletions
diff --git a/rules/distdir-way-opts.mk b/rules/distdir-way-opts.mk
index 8c0377eff8..93bc60b6b1 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