From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751982AbdBOPZW (ORCPT ); Wed, 15 Feb 2017 10:25:22 -0500 Received: from mailapp01.imgtec.com ([195.59.15.196]:63613 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750760AbdBOPZV (ORCPT ); Wed, 15 Feb 2017 10:25:21 -0500 Subject: Re: [PATCH] tools/lib/api: allow the linker to be overridden To: Arnaldo Carvalho de Melo References: <1487170590-17970-1-git-send-email-marcin.nowakowski@imgtec.com> <20170215151833.GA2196@redhat.com> CC: From: Marcin Nowakowski Message-ID: <31b37fa7-42db-a863-7fa8-92f1396fcb38@imgtec.com> Date: Wed, 15 Feb 2017 16:25:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170215151833.GA2196@redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.2.5] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnaldo, On 15.02.2017 16:18, Arnaldo Carvalho de Melo wrote: > Em Wed, Feb 15, 2017 at 03:56:30PM +0100, Marcin Nowakowski escreveu: >> Makefile in lib/api unconditionally sets the LD to support >> cross-compilation. However, when invoked from within the perf build LD >> may be already appropriately set for a given platform and the override >> may lead to cross-compilation without appropriate linker flags. > >> Change the unconditional override to a conditional one. >> >> Fixes: 37b4e2020a5f ('perf build: Add EXTRA_LDFLAGS option to makefile') >> Fixes: 703e01652d25 ('tools lib api: Respect CROSS_COMPILE for the linker') >> >> Signed-off-by: Marcin Nowakowski >> --- >> tools/lib/api/Makefile | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/tools/lib/api/Makefile b/tools/lib/api/Makefile >> index adba83b..42e00c4 100644 >> --- a/tools/lib/api/Makefile >> +++ b/tools/lib/api/Makefile >> @@ -10,7 +10,7 @@ endif >> >> CC = $(CROSS_COMPILE)gcc >> AR = $(CROSS_COMPILE)ar >> -LD = $(CROSS_COMPILE)ld >> +LD ?= $(CROSS_COMPILE)ld > > Looks strange to do this just for LD, what about CC and AR? > > - Arnaldo I agree it looks a bit strange and at first I was thinking about doing that, but the problem is that for eg. CC that doesn't work, because make internally defines CC. Perf uses a workaround for this: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/tools/perf/Makefile.perf#n136 so if you want I could move that to lib/api as well. On the other hand the main problem that exists here is that for CC, all extra variables are handled by EXTRA_CFLAGS variable that is used by various makefiles, while there is no such 'global' equivalent for LDFLAGS that could be used and this was 'merged' into the LD in commit 37b4e2020a5f (and later broken again by 703e01652d25). Marcin