aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlexey Brodkin <Alexey.Brodkin@synopsys.com>2015-07-14 05:05:20 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-07-15 10:57:28 -0400
commit3c71ba3f80bbd476bbfb2a008da9b676031cbd32 (patch)
tree62ee9c21670b825e50b7c8e6d92f0b2948977ec2 /tools
parenta7fde09a78a8ae40b81cfb5096c3cefef6c078c9 (diff)
perf tools: Really allow to specify custom CC, AR or LD
Commit 5ef7bbb09f7b ("perf tools: Allow to specify custom linker command") was meant to enable usage non $(CROSS_COMPILE)ld linker during perf building. But implementation didn't take into account the fact that LD is a pre-defined variable in GNU Make. I.e. it is always defined. Which means there's no point to check "LD ?= ..." because it will never succeed. And so LD will be either that explicitly passed to make like this: ------->8------- make LD=path_to_my_ld ... ------->8------- or default value, which is host's "ld". Latter leads to failure of cross-linkage because instead of cross linker "$(CROSS_COMPILE)ld" host's "ld" is used. Fortunately there's a way to do correct substitution of $(CROSS_COMPILE)ld with user defined LD on command-line. As a reference was used implementation in "tools/lib/traceevent/Makefile". Build tested for x86_64 and ARC. Thanks Jiri for this hint. Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com> Fixes: 5ef7bbb09f7b ("perf tools: Allow to specify custom linker command") Cc: Aaro Koskinen <aaro.koskinen@nokia.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Vineet Gupta <Vineet.Gupta1@synopsys.com> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: linux-arch@vger.kernel.org Link: http://lkml.kernel.org/r/1436864720-26316-1-git-send-email-abrodkin@synopsys.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/Makefile.perf19
1 files changed, 16 insertions, 3 deletions
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 7a4b549214e3..bba34636b733 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -109,9 +109,22 @@ $(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD
109 $(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) 109 $(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
110 $(Q)touch $(OUTPUT)PERF-VERSION-FILE 110 $(Q)touch $(OUTPUT)PERF-VERSION-FILE
111 111
112CC = $(CROSS_COMPILE)gcc 112# Makefiles suck: This macro sets a default value of $(2) for the
113LD ?= $(CROSS_COMPILE)ld 113# variable named by $(1), unless the variable has been set by
114AR = $(CROSS_COMPILE)ar 114# environment or command line. This is necessary for CC and AR
115# because make sets default values, so the simpler ?= approach
116# won't work as expected.
117define allow-override
118 $(if $(or $(findstring environment,$(origin $(1))),\
119 $(findstring command line,$(origin $(1)))),,\
120 $(eval $(1) = $(2)))
121endef
122
123# Allow setting CC and AR and LD, or setting CROSS_COMPILE as a prefix.
124$(call allow-override,CC,$(CROSS_COMPILE)gcc)
125$(call allow-override,AR,$(CROSS_COMPILE)ar)
126$(call allow-override,LD,$(CROSS_COMPILE)ld)
127
115PKG_CONFIG = $(CROSS_COMPILE)pkg-config 128PKG_CONFIG = $(CROSS_COMPILE)pkg-config
116 129
117RM = rm -f 130RM = rm -f