Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754102AbbGRDWm (ORCPT ); Fri, 17 Jul 2015 23:22:42 -0400 Received: from terminus.zytor.com ([198.137.202.10]:56545 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753545AbbGRDWk (ORCPT ); Fri, 17 Jul 2015 23:22:40 -0400 Date: Fri, 17 Jul 2015 20:22:05 -0700 From: tip-bot for Alexey Brodkin Message-ID: Cc: mingo@kernel.org, Alexey.Brodkin@synopsys.com, hpa@zytor.com, tglx@linutronix.de, abrodkin@synopsys.com, linux-kernel@vger.kernel.org, aaro.koskinen@nokia.com, a.p.zijlstra@chello.nl, acme@redhat.com, Vineet.Gupta1@synopsys.com, vgupta@synopsys.com, paulus@samba.org, jolsa@kernel.org Reply-To: jolsa@kernel.org, vgupta@synopsys.com, paulus@samba.org, Vineet.Gupta1@synopsys.com, a.p.zijlstra@chello.nl, aaro.koskinen@nokia.com, acme@redhat.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, abrodkin@synopsys.com, mingo@kernel.org, hpa@zytor.com, Alexey.Brodkin@synopsys.com In-Reply-To: <1436864720-26316-1-git-send-email-abrodkin@synopsys.com> References: <1436864720-26316-1-git-send-email-abrodkin@synopsys.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf tools: Really allow to specify custom CC, AR or LD Git-Commit-ID: 3c71ba3f80bbd476bbfb2a008da9b676031cbd32 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3319 Lines: 88 Commit-ID: 3c71ba3f80bbd476bbfb2a008da9b676031cbd32 Gitweb: http://git.kernel.org/tip/3c71ba3f80bbd476bbfb2a008da9b676031cbd32 Author: Alexey Brodkin AuthorDate: Tue, 14 Jul 2015 12:05:20 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 15 Jul 2015 11:57:28 -0300 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 Fixes: 5ef7bbb09f7b ("perf tools: Allow to specify custom linker command") Cc: Aaro Koskinen Cc: Jiri Olsa Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Vineet Gupta Cc: Vineet Gupta 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 --- tools/perf/Makefile.perf | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 7a4b549..bba3463 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -109,9 +109,22 @@ $(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD $(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) $(Q)touch $(OUTPUT)PERF-VERSION-FILE -CC = $(CROSS_COMPILE)gcc -LD ?= $(CROSS_COMPILE)ld -AR = $(CROSS_COMPILE)ar +# Makefiles suck: This macro sets a default value of $(2) for the +# variable named by $(1), unless the variable has been set by +# environment or command line. This is necessary for CC and AR +# because make sets default values, so the simpler ?= approach +# won't work as expected. +define allow-override + $(if $(or $(findstring environment,$(origin $(1))),\ + $(findstring command line,$(origin $(1)))),,\ + $(eval $(1) = $(2))) +endef + +# Allow setting CC and AR and LD, or setting CROSS_COMPILE as a prefix. +$(call allow-override,CC,$(CROSS_COMPILE)gcc) +$(call allow-override,AR,$(CROSS_COMPILE)ar) +$(call allow-override,LD,$(CROSS_COMPILE)ld) + PKG_CONFIG = $(CROSS_COMPILE)pkg-config RM = rm -f -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/