Revert "kbuild: remove libelf checks from top Makefile"
This reverts commit 0d989ac2c9.
Android kernel isn't ready for this change yet. Here's why:
There are a couple of different methods for linking the Android
kernel presently, hermetically and not. When *not* building
hermetically, the kernel is linked against locally installed
libraries (OpenSSL, LibElf, etc), usually installed by the distro.
Since these are usually fully fledged versions, they're usually
sufficient for any possible combination of build options.
However, when building hermetically (the intended default), the kernel
is linked against libraries contained in the `repo` controlled AOSP
repositories. This is not a problem for the vast majority of the
important builds, but x86 allmodconfig builds require more
functionality than is presently provided.
This revert changes the presence of LibElf to be voluntary again.
Meaning that we do not have to insist on the presence of a locally
installed instance.
Once OpenSSL (currently provided via BoringSSL) is upgraded to a more
featureful offering, we can consider re-inclusion of this patch.
Change-Id: I810139b034e1a6c2db4dc9fa8871279f5edf215d
Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
78
Makefile
78
Makefile
@@ -1117,6 +1117,41 @@ export INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE)
|
||||
MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
|
||||
export MODLIB
|
||||
|
||||
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
|
||||
|
||||
# tools/bpf/resolve_btfids directory might not exist
|
||||
# in output directory, skip its clean in that case
|
||||
resolve_btfids_clean:
|
||||
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 extmod_prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
|
||||
@@ -1266,7 +1301,7 @@ prepare0: archprepare
|
||||
$(Q)$(MAKE) $(build)=.
|
||||
|
||||
# All the preparing..
|
||||
prepare: prepare0
|
||||
prepare: prepare0 prepare-objtool prepare-resolve_btfids
|
||||
|
||||
PHONY += remove-stale-files
|
||||
remove-stale-files:
|
||||
@@ -1283,6 +1318,26 @@ uapi-asm-generic:
|
||||
$(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
|
||||
generic=include/uapi/asm-generic
|
||||
|
||||
PHONY += prepare-objtool prepare-resolve_btfids
|
||||
prepare-objtool: $(objtool_target)
|
||||
ifeq ($(SKIP_STACK_VALIDATION),1)
|
||||
ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
|
||||
@echo "error: Cannot generate __mcount_loc for CONFIG_DYNAMIC_FTRACE=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
|
||||
@false
|
||||
endif
|
||||
ifdef CONFIG_UNWINDER_ORC
|
||||
@echo "error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
|
||||
@false
|
||||
else
|
||||
@echo "warning: Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
|
||||
endif
|
||||
endif
|
||||
|
||||
prepare-resolve_btfids: $(resolve_btfids_target)
|
||||
ifeq ($(ERROR_RESOLVE_BTFIDS),1)
|
||||
@echo "error: Cannot resolve BTF IDs for CONFIG_DEBUG_INFO_BTF, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
|
||||
@false
|
||||
endif
|
||||
# Generate some files
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@@ -1351,27 +1406,6 @@ scripts_unifdef: scripts_basic
|
||||
# ---------------------------------------------------------------------------
|
||||
# Tools
|
||||
|
||||
ifdef CONFIG_STACK_VALIDATION
|
||||
prepare: tools/objtool
|
||||
endif
|
||||
|
||||
ifdef CONFIG_BPF
|
||||
ifdef CONFIG_DEBUG_INFO_BTF
|
||||
prepare: tools/bpf/resolve_btfids
|
||||
endif
|
||||
endif
|
||||
|
||||
PHONY += resolve_btfids_clean
|
||||
|
||||
resolve_btfids_O = $(abspath $(objtree))/tools/bpf/resolve_btfids
|
||||
|
||||
# tools/bpf/resolve_btfids directory might not exist
|
||||
# in output directory, skip its clean in that case
|
||||
resolve_btfids_clean:
|
||||
ifneq ($(wildcard $(resolve_btfids_O)),)
|
||||
$(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
|
||||
endif
|
||||
|
||||
# Clear a bunch of variables before executing the submake
|
||||
ifeq ($(quiet),silent_)
|
||||
tools_silent=s
|
||||
|
||||
@@ -219,6 +219,7 @@ endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
|
||||
|
||||
ifdef CONFIG_STACK_VALIDATION
|
||||
ifndef CONFIG_LTO_CLANG
|
||||
ifneq ($(SKIP_STACK_VALIDATION),1)
|
||||
|
||||
__objtool_obj := $(objtree)/tools/objtool/objtool
|
||||
|
||||
@@ -232,6 +233,7 @@ objtool_obj = $(if $(patsubst y%,, \
|
||||
$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
|
||||
$(__objtool_obj))
|
||||
|
||||
endif # SKIP_STACK_VALIDATION
|
||||
endif # CONFIG_LTO_CLANG
|
||||
endif # CONFIG_STACK_VALIDATION
|
||||
|
||||
|
||||
@@ -39,10 +39,12 @@ prelink-ext := .lto
|
||||
# so let's now process the prelinked binary before we link the module.
|
||||
|
||||
ifdef CONFIG_STACK_VALIDATION
|
||||
ifneq ($(SKIP_STACK_VALIDATION),1)
|
||||
cmd_ld_ko_o += \
|
||||
$(objtree)/tools/objtool/objtool $(objtool_args) \
|
||||
$(@:.ko=$(prelink-ext).o);
|
||||
|
||||
endif # SKIP_STACK_VALIDATION
|
||||
endif # CONFIG_STACK_VALIDATION
|
||||
|
||||
endif # CONFIG_LTO_CLANG
|
||||
|
||||
Reference in New Issue
Block a user