Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1581382 > unrolled thread

[PATCH] tools/lib/api: allow the linker to be overridden

Started byMarcin Nowakowski <marcin.nowakowski@imgtec.com>
First post2017-02-15 16:00 +0100
Last post2017-02-15 16:30 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] tools/lib/api: allow the linker to be overridden Marcin Nowakowski <marcin.nowakowski@imgtec.com> - 2017-02-15 16:00 +0100
    Re: [PATCH] tools/lib/api: allow the linker to be overridden Arnaldo Carvalho de Melo <acme@redhat.com> - 2017-02-15 16:20 +0100
      Re: [PATCH] tools/lib/api: allow the linker to be overridden Marcin Nowakowski <marcin.nowakowski@imgtec.com> - 2017-02-15 16:30 +0100

#1581382 — [PATCH] tools/lib/api: allow the linker to be overridden

FromMarcin Nowakowski <marcin.nowakowski@imgtec.com>
Date2017-02-15 16:00 +0100
Subject[PATCH] tools/lib/api: allow the linker to be overridden
Message-ID<tb9dM-1hF-17@gated-at.bofh.it>
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 <marcin.nowakowski@imgtec.com>
---
 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
 
 MAKEFLAGS += --no-print-directory
 
-- 
2.7.4

[toc] | [next] | [standalone]


#1581393

FromArnaldo Carvalho de Melo <acme@redhat.com>
Date2017-02-15 16:20 +0100
Message-ID<tb9x8-1Fk-15@gated-at.bofh.it>
In reply to#1581382
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 <marcin.nowakowski@imgtec.com>
> ---
>  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
  
>  MAKEFLAGS += --no-print-directory
>  
> -- 
> 2.7.4

[toc] | [prev] | [next] | [standalone]


#1581396

FromMarcin Nowakowski <marcin.nowakowski@imgtec.com>
Date2017-02-15 16:30 +0100
Message-ID<tb9GO-1II-15@gated-at.bofh.it>
In reply to#1581393
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 <marcin.nowakowski@imgtec.com>
>> ---
>>  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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web