Linux-KBuild Archive mirror
 help / color / mirror / Atom feed
* [PATCH] kbuild: improve libelf detection
@ 2021-01-12 19:00 Alistair Delva
  2021-01-13 12:39 ` Rolf Eike Beer
  0 siblings, 1 reply; 2+ messages in thread
From: Alistair Delva @ 2021-01-12 19:00 UTC (permalink / raw
  To: linux-kernel; +Cc: kernel-team, linux-kbuild, Masahiro Yamada, Rolf Eike Beer

When `pkg-config --libs' wasn't used or didn't return anything useful,
the test for libelf would fail even if the headers and libraries were
available to kbuild via KBUILD_HOSTCFLAGS and KBUILD_HOSTLDFLAGS.

This makes the check in the core Makefile match the check that is done
in tools/objtool/Makefile. Specifically, the C compiler is passed the
full KBUILD_HOSTCFLAGS and KBUILD_HOSTLDFLAGS, which may have set up
additional sysroot/include/library search paths to find libelf.

Cc: kernel-team@android.com
Cc: linux-kbuild@vger.kernel.org
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Alistair Delva <adelva@google.com>
---
 Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 9e73f82e0d86..3269e155fbe4 100644
--- a/Makefile
+++ b/Makefile
@@ -1074,8 +1074,9 @@ export mod_sign_cmd
 
 HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
 
-has_libelf = $(call try-run,\
-               echo "int main() {}" | $(HOSTCC) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0)
+has_libelf := $(call try-run,\
+                echo "int main() {}" | \
+                $(HOSTCC) $(KBUILD_HOSTCFLAGS) -xc -o /dev/null $(KBUILD_HOSTLDFLAGS) $(HOST_LIBELF_LIBS) -,1,0)
 
 ifdef CONFIG_STACK_VALIDATION
   ifeq ($(has_libelf),1)
-- 
2.29.2


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

* Re: [PATCH] kbuild: improve libelf detection
  2021-01-12 19:00 [PATCH] kbuild: improve libelf detection Alistair Delva
@ 2021-01-13 12:39 ` Rolf Eike Beer
  0 siblings, 0 replies; 2+ messages in thread
From: Rolf Eike Beer @ 2021-01-13 12:39 UTC (permalink / raw
  To: linux-kernel, Alistair Delva; +Cc: kernel-team, linux-kbuild, Masahiro Yamada

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

Am Dienstag, 12. Januar 2021, 20:00:10 CET schrieb Alistair Delva:
> When `pkg-config --libs' wasn't used or didn't return anything useful,
> the test for libelf would fail even if the headers and libraries were
> available to kbuild via KBUILD_HOSTCFLAGS and KBUILD_HOSTLDFLAGS.
> 
> This makes the check in the core Makefile match the check that is done
> in tools/objtool/Makefile. Specifically, the C compiler is passed the
> full KBUILD_HOSTCFLAGS and KBUILD_HOSTLDFLAGS, which may have set up
> additional sysroot/include/library search paths to find libelf.

Sounds plausible.

-- 
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] 2+ messages in thread

end of thread, other threads:[~2021-01-13 12:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-12 19:00 [PATCH] kbuild: improve libelf detection Alistair Delva
2021-01-13 12:39 ` 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 read-only IMAP folder(s) and NNTP newsgroup(s).