All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alistair Delva <adelva@google.com>
To: linux-kernel@vger.kernel.org
Cc: kernel-team@android.com, linux-kbuild@vger.kernel.org,
	Masahiro Yamada <masahiroy@kernel.org>,
	Rolf Eike Beer <eb@emlix.com>
Subject: [PATCH] kbuild: improve libelf detection
Date: Tue, 12 Jan 2021 19:00:10 +0000	[thread overview]
Message-ID: <20210112190010.1582888-1-adelva@google.com> (raw)

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


             reply	other threads:[~2021-01-12 19:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 19:00 Alistair Delva [this message]
2021-01-13 12:39 ` [PATCH] kbuild: improve libelf detection Rolf Eike Beer

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=20210112190010.1582888-1-adelva@google.com \
    --to=adelva@google.com \
    --cc=eb@emlix.com \
    --cc=kernel-team@android.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    /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.