From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: linux-kbuild@vger.kernel.org
Cc: Ingo Molnar <mingo@redhat.com>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Bernd Edlinger <bernd.edlinger@hotmail.de>,
Borislav Petkov <bp@suse.de>, Sam Ravnborg <sam@ravnborg.org>,
Masahiro Yamada <yamada.masahiro@socionext.com>,
Michal Marek <michal.lkml@markovi.net>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] objtool: move libelf check out of top Makefile
Date: Tue, 16 Oct 2018 18:10:52 +0900 [thread overview]
Message-ID: <1539681053-24388-3-git-send-email-yamada.masahiro@socionext.com> (raw)
In-Reply-To: <1539681053-24388-1-git-send-email-yamada.masahiro@socionext.com>
Bernd Edlinger reports:
The next make after an oldconfig reads in the outdated
include/config/auto.conf which can kill the make before
it is able to call the syncconfig target.
$ make defconfig
*** Default configuration is based on 'x86_64_defconfig'
$ make
scripts/kconfig/conf --syncconfig Kconfig
Makefile:936: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y,
please install libelf-dev, libelf-devel or elfutils-libelf-devel". Stop.
$ sed -i s/CONFIG_UNWINDER_ORC=y// .configs
$ make oldconfig
Choose kernel unwinder
> 1. ORC unwinder (UNWINDER_ORC) (NEW)
2. Frame pointer unwinder (UNWINDER_FRAME_POINTER)
choice[1-2?]: 2
$ make
Makefile:936: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y,
please install libelf-dev, libelf-devel or elfutils-libelf-devel". Stop.
I tried to fix it by moving the libelf evaluation to the Kconfig
stage [1], but it was rejected.
Kconfig is now able to run shell commands to evaluate any prerequisites
needed to enable CONFIG options.
For example, as shown in commit 2a61f4747eea ("stack-protector: test
compiler capability in Kconfig and drop AUTO mode"), the new Kconfig
syntax is useful to evaluate target compiler capabilities.
However, disabling the CONFIG option silently just because of missing
libelf would not be a preferred behavior; in this case, installing an
appropriate package will solve the problem. Hence, this check will be
kept in a makefile, but somewhere else than the top Makefile.
Move the check to scripts/Makefile.toolcheck so that it is run after
syncconfig.
Another behavioral change is, missing libelf for CONFIG_STACK_VALIDATION
was previously a warning, but now a error.
[1] https://patchwork.kernel.org/patch/10516049/
Reported-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
Makefile | 21 +++------------------
scripts/Makefile.build | 2 --
scripts/Makefile.toolcheck | 5 +++++
3 files changed, 8 insertions(+), 20 deletions(-)
diff --git a/Makefile b/Makefile
index 23a204a..71940b7 100644
--- a/Makefile
+++ b/Makefile
@@ -949,23 +949,6 @@ mod_sign_cmd = true
endif
export mod_sign_cmd
-ifdef CONFIG_STACK_VALIDATION
- has_libelf := $(call try-run,\
- echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0)
- ifeq ($(has_libelf),1)
- objtool_target := tools/objtool FORCE
- else
- ifdef CONFIG_UNWINDER_ORC
- $(error "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel")
- else
- $(warning "Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel")
- endif
- SKIP_STACK_VALIDATION := 1
- export SKIP_STACK_VALIDATION
- endif
-endif
-
-
ifeq ($(KBUILD_EXTMOD),)
core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
@@ -1115,7 +1098,9 @@ uapi-asm-generic:
src=uapi/asm obj=arch/$(SRCARCH)/include/generated/uapi/asm
PHONY += prepare-objtool
-prepare-objtool: $(objtool_target)
+ifdef CONFIG_STACK_VALIDATION
+prepare-objtool: tools/objtool
+endif
# Generate some files
# ---------------------------------------------------------------------------
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 54da4b0..e9dabe4 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -233,7 +233,6 @@ endif # CC_USING_RECORD_MCOUNT
endif # CONFIG_FTRACE_MCOUNT_RECORD
ifdef CONFIG_STACK_VALIDATION
-ifneq ($(SKIP_STACK_VALIDATION),1)
__objtool_obj := $(objtree)/tools/objtool/objtool
@@ -270,7 +269,6 @@ objtool_obj = $(if $(patsubst y%,, \
$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
$(__objtool_obj))
-endif # SKIP_STACK_VALIDATION
endif # CONFIG_STACK_VALIDATION
# Rebuild all objects when objtool changes, or is enabled/disabled.
diff --git a/scripts/Makefile.toolcheck b/scripts/Makefile.toolcheck
index f3c165d..bc26fc0 100644
--- a/scripts/Makefile.toolcheck
+++ b/scripts/Makefile.toolcheck
@@ -12,6 +12,11 @@ include include/config/auto.conf
__toolcheck:
@:
+chk_stack_validation = echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -
+msg_stack_validation = "libelf is necessary for building the objtool." \
+ "Please install libelf-dev, libelf-devel or elfutils-libelf-devel."
+toolcheck-$(CONFIG_STACK_VALIDATION) += stack_validation
+
PHONY += $(toolcheck-y)
__toolcheck: $(toolcheck-y)
--
2.7.4
next prev parent reply other threads:[~2018-10-16 9:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-16 9:10 [PATCH 0/3] kbuild: add scripts/Makefile.toolcheck to check necessary host tools Masahiro Yamada
2018-10-16 9:10 ` [PATCH 1/3] kbuild: provide a new place " Masahiro Yamada
2018-10-16 15:47 ` Sam Ravnborg
2018-10-16 9:10 ` Masahiro Yamada [this message]
2018-10-16 14:25 ` [PATCH 2/3] objtool: move libelf check out of top Makefile Josh Poimboeuf
2018-10-16 15:51 ` Masahiro Yamada
2018-10-16 16:15 ` Josh Poimboeuf
2018-10-19 6:04 ` Masahiro Yamada
2018-10-19 19:28 ` Josh Poimboeuf
2018-10-16 9:10 ` [PATCH 3/3] kbuild: check the presence of lzo and lz4 tools when necessary Masahiro Yamada
2018-10-16 19:54 ` Borislav Petkov
2018-10-17 8:59 ` Masahiro Yamada
2018-10-17 9:10 ` Borislav Petkov
2018-10-17 9:25 ` Masahiro Yamada
2018-10-17 9:47 ` Borislav Petkov
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=1539681053-24388-3-git-send-email-yamada.masahiro@socionext.com \
--to=yamada.masahiro@socionext.com \
--cc=bernd.edlinger@hotmail.de \
--cc=bp@suse.de \
--cc=jpoimboe@redhat.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.lkml@markovi.net \
--cc=mingo@redhat.com \
--cc=sam@ravnborg.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 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).