Makefile: Do not check for libelf when building OOT module
authorBen Hutchings <ben@decadent.org.uk>
Mon, 7 Sep 2020 02:38:04 +0000 (03:38 +0100)
committerSalvatore Bonaccorso <carnil@debian.org>
Fri, 21 Oct 2022 20:24:21 +0000 (21:24 +0100)
When building out-of-tree modules, the necessary tools should have
already been built.  We therefore do not need libelf-dev to be
installed.

This effectively reverts commit 9f0c18aec620 "objtool: Fix
CONFIG_STACK_VALIDATION=y warning for out-of-tree modules", and
similarly moves the check introduced by commit 33a57ce0a54d "bpf:
Compile resolve_btfids tool at kernel compilation start".

Gbp-Pq: Topic debian
Gbp-Pq: Name makefile-do-not-check-for-libelf-when-building-oot-module.patch

Makefile

index e8c2aebab26a7bc47bf73e654c6444c56140b559..86650e6ceb6b3d7fbf4af787ceac395f683f668f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1095,18 +1095,6 @@ 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) $(KBUILD_HOSTLDFLAGS) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0)
-
-ifdef CONFIG_STACK_VALIDATION
-  ifeq ($(has_libelf),1)
-    objtool_target := tools/objtool FORCE
-  else
-    SKIP_STACK_VALIDATION := 1
-    export SKIP_STACK_VALIDATION
-  endif
-endif
-
 PHONY += resolve_btfids_clean
 
 resolve_btfids_O = $(abspath $(objtree))/tools/bpf/resolve_btfids
@@ -1118,16 +1106,6 @@ ifneq ($(wildcard $(resolve_btfids_O)),)
        $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
 endif
 
-ifdef CONFIG_BPF
-ifdef CONFIG_DEBUG_INFO_BTF
-  ifeq ($(has_libelf),1)
-    resolve_btfids_target := tools/bpf/resolve_btfids FORCE
-  else
-    ERROR_RESOLVE_BTFIDS := 1
-  endif
-endif # CONFIG_DEBUG_INFO_BTF
-endif # CONFIG_BPF
-
 PHONY += prepare0
 
 export MODORDER := $(extmod-prefix)modules.order
@@ -1249,6 +1227,28 @@ uapi-asm-generic:
        $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
        generic=include/uapi/asm-generic
 
+has_libelf = $(call try-run,\
+               echo "int main() {}" | $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0)
+
+ifdef CONFIG_STACK_VALIDATION
+  ifeq ($(has_libelf),1)
+    objtool_target := tools/objtool FORCE
+  else
+    SKIP_STACK_VALIDATION := 1
+    export SKIP_STACK_VALIDATION
+  endif
+endif
+
+ifdef CONFIG_BPF
+ifdef CONFIG_DEBUG_INFO_BTF
+  ifeq ($(has_libelf),1)
+    resolve_btfids_target := tools/bpf/resolve_btfids FORCE
+  else
+    ERROR_RESOLVE_BTFIDS := 1
+  endif
+endif # CONFIG_DEBUG_INFO_BTF
+endif # CONFIG_BPF
+
 PHONY += prepare-objtool prepare-resolve_btfids
 prepare-objtool: $(objtool_target)
 ifeq ($(SKIP_STACK_VALIDATION),1)