All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Alexey Brodkin <Alexey.Brodkin@synopsys.com>,
	Alexey Brodkin <abrodkin@synopsys.com>,
	Aaro Koskinen <aaro.koskinen@nokia.com>,
	Jiri Olsa <jolsa@kernel.org>, Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Vineet Gupta <Vineet.Gupta1@synopsys.com>,
	Vineet Gupta <vgupta@synopsys.com>,
	linux-arch@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 2/2] perf tools: Really allow to specify custom CC, AR or LD
Date: Wed, 15 Jul 2015 12:20:08 -0300	[thread overview]
Message-ID: <1436973608-9271-3-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1436973608-9271-1-git-send-email-acme@kernel.org>

From: Alexey Brodkin <Alexey.Brodkin@synopsys.com>

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>
---
 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 7a4b549214e3..bba34636b733 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
-- 
2.1.0


  parent reply	other threads:[~2015-07-15 15:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-15 15:20 [GIT PULL 0/2] perf/urgent fixes Arnaldo Carvalho de Melo
2015-07-15 15:20 ` [PATCH 1/2] perf auxtrace: Fix misplaced check for HAVE_SYNC_COMPARE_AND_SWAP_SUPPORT Arnaldo Carvalho de Melo
2015-07-15 15:20 ` Arnaldo Carvalho de Melo [this message]
2015-07-17 12:17 ` [GIT PULL 0/2] perf/urgent fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1436973608-9271-3-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=Alexey.Brodkin@synopsys.com \
    --cc=Vineet.Gupta1@synopsys.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=aaro.koskinen@nokia.com \
    --cc=abrodkin@synopsys.com \
    --cc=acme@redhat.com \
    --cc=jolsa@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulus@samba.org \
    --cc=vgupta@synopsys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.