linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH linux] objtool: fix pkg-config query in case of cross-compilation
@ 2019-04-11  8:39 Nicolas Dichtel
  2019-04-11  8:52 ` Rolf Eike Beer
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Dichtel @ 2019-04-11  8:39 UTC (permalink / raw)
  To: tglx, jpoimboe, eb, yamada.masahiro, peterz
  Cc: linux-kbuild, linux-kernel, Nicolas Dichtel

In case of cross-compilation, there may be two pkg-config tools, one for
the host and one for the target. Enable to override the default name.

Fixes: 056d28d135bc ("objtool: Query pkg-config for libelf location")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 Makefile               | 3 ++-
 tools/objtool/Makefile | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 15c8251d4d5e..f12ca3598fc4 100644
--- a/Makefile
+++ b/Makefile
@@ -953,7 +953,8 @@ mod_sign_cmd = true
 endif
 export mod_sign_cmd
 
-HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
+export HOST_PKG_CONFIG ?= pkg-config
+HOST_LIBELF_LIBS = $(shell $(HOST_PKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
 
 ifdef CONFIG_STACK_VALIDATION
   has_libelf := $(call try-run,\
diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
index 53f8be0f4a1f..4e229e77aacf 100644
--- a/tools/objtool/Makefile
+++ b/tools/objtool/Makefile
@@ -25,8 +25,8 @@ LIBSUBCMD		= $(LIBSUBCMD_OUTPUT)libsubcmd.a
 OBJTOOL    := $(OUTPUT)objtool
 OBJTOOL_IN := $(OBJTOOL)-in.o
 
-LIBELF_FLAGS := $(shell pkg-config libelf --cflags 2>/dev/null)
-LIBELF_LIBS  := $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
+LIBELF_FLAGS := $(shell $(HOST_PKG_CONFIG) libelf --cflags 2>/dev/null)
+LIBELF_LIBS  := $(shell $(HOST_PKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
 
 all: $(OBJTOOL)
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH linux] objtool: fix pkg-config query in case of cross-compilation
  2019-04-11  8:39 [PATCH linux] objtool: fix pkg-config query in case of cross-compilation Nicolas Dichtel
@ 2019-04-11  8:52 ` Rolf Eike Beer
  2019-04-11  9:26   ` Nicolas Dichtel
  0 siblings, 1 reply; 4+ messages in thread
From: Rolf Eike Beer @ 2019-04-11  8:52 UTC (permalink / raw)
  To: Nicolas Dichtel
  Cc: tglx, jpoimboe, yamada.masahiro, peterz, linux-kbuild, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1412 bytes --]

Am Donnerstag, 11. April 2019, 10:39:40 CEST schrieb Nicolas Dichtel:
> In case of cross-compilation, there may be two pkg-config tools, one for
> the host and one for the target. Enable to override the default name.
> 
> Fixes: 056d28d135bc ("objtool: Query pkg-config for libelf location")
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

If you do that, you have to fix a lot of other places, too. This starts in 
scripts/kconfig/ and also includes e.g. tools/testing/.

Usually you have pkg-config for host and ${target_platform}-pkg-config for the 
target, and the PKG_CONFIG variable for the target, usually initialized to $
(CROSS_COMPILE)pkg-config. I have sent a bunch of patches to replace the usage 
of plain pkg-config at several places with the cross-aware version, but sadly 
a lot of them have not been picked up. It break cross-building tests basically 
all the time. One example is here: 

https://marc.info/?l=linux-acpi&m=153544231529066&w=2

For me it looks like you are trying to go into the wrong direction.

Greetings,

Eike
-- 
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 313 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH linux] objtool: fix pkg-config query in case of cross-compilation
  2019-04-11  8:52 ` Rolf Eike Beer
@ 2019-04-11  9:26   ` Nicolas Dichtel
  2019-04-11 13:50     ` Rolf Eike Beer
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Dichtel @ 2019-04-11  9:26 UTC (permalink / raw)
  To: Rolf Eike Beer
  Cc: tglx, jpoimboe, yamada.masahiro, peterz, linux-kbuild, linux-kernel

Le 11/04/2019 à 10:52, Rolf Eike Beer a écrit :
> Am Donnerstag, 11. April 2019, 10:39:40 CEST schrieb Nicolas Dichtel:
>> In case of cross-compilation, there may be two pkg-config tools, one for
>> the host and one for the target. Enable to override the default name.
>>
>> Fixes: 056d28d135bc ("objtool: Query pkg-config for libelf location")
>> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> 
> If you do that, you have to fix a lot of other places, too. This starts in 
> scripts/kconfig/ and also includes e.g. tools/testing/.
> 
> Usually you have pkg-config for host and ${target_platform}-pkg-config for the 
My use case was for buildroot, which define pkg-config and host-pkgconf. In
fact, I've just seen that a buildroot patch was accepted for this problem:
https://patchwork.ozlabs.org/patch/1081379/


Regards,
Nicolas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH linux] objtool: fix pkg-config query in case of cross-compilation
  2019-04-11  9:26   ` Nicolas Dichtel
@ 2019-04-11 13:50     ` Rolf Eike Beer
  0 siblings, 0 replies; 4+ messages in thread
From: Rolf Eike Beer @ 2019-04-11 13:50 UTC (permalink / raw)
  To: nicolas.dichtel
  Cc: tglx, jpoimboe, yamada.masahiro, peterz, linux-kbuild, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1962 bytes --]

Am Donnerstag, 11. April 2019, 11:26:12 CEST schrieb Nicolas Dichtel:
> Le 11/04/2019 à 10:52, Rolf Eike Beer a écrit :
> > Am Donnerstag, 11. April 2019, 10:39:40 CEST schrieb Nicolas Dichtel:
> >> In case of cross-compilation, there may be two pkg-config tools, one for
> >> the host and one for the target. Enable to override the default name.
> >> 
> >> Fixes: 056d28d135bc ("objtool: Query pkg-config for libelf location")
> >> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> > 
> > If you do that, you have to fix a lot of other places, too. This starts in
> > scripts/kconfig/ and also includes e.g. tools/testing/.
> > 
> > Usually you have pkg-config for host and ${target_platform}-pkg-config for
> > the
> My use case was for buildroot, which define pkg-config and host-pkgconf. In
> fact, I've just seen that a buildroot patch was accepted for this problem:
> https://patchwork.ozlabs.org/patch/1081379/

I agree that it makes sense to have both host and target pkg-config 
configurable. But IMHO that must happen in a central place (i.e. ./Makefile), 
and it has to be used everywhere. Currently PKG_CONFIG is defined at multiple 
places, sometimes host, sometimes target, and often pkg-config is called 
directly, also mixing both usages.

So, IMHO, if you want to fix this: fix it once and for all in the whole 
kernel, not just one place. What I have introduced was just the same as 
kconfig is using to find the dependencies for some of the *config variants, so 
this usecase would break for you anyway, although I don't think anyone in 
buildroot will notice this.

Eike
-- 
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 313 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-11 13:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-11  8:39 [PATCH linux] objtool: fix pkg-config query in case of cross-compilation Nicolas Dichtel
2019-04-11  8:52 ` Rolf Eike Beer
2019-04-11  9:26   ` Nicolas Dichtel
2019-04-11 13:50     ` Rolf Eike Beer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).