From: Steven Rostedt <rostedt@goodmis.org>
To: "Joel Fernandes (Google)" <joel@joelfernandes.org>
Cc: linux-kernel@vger.kernel.org,
Alexandre Torgue <alexandre.torgue@st.com>,
Andrew Morton <akpm@linux-foundation.org>,
ast@kernel.org, atishp04@gmail.com, dancol@google.com,
Dan Williams <dan.j.williams@intel.com>,
gregkh@linuxfoundation.org, Ingo Molnar <mingo@redhat.com>,
Jonathan Corbet <corbet@lwn.net>,
karim.yaghmour@opersys.com, Kees Cook <keescook@chromium.org>,
kernel-team@android.com, linux-doc@vger.kernel.org,
linux-kselftest@vger.kernel.org,
Manoj Rao <linux@manojrajarao.com>,
Masahiro Yamada <yamada.masahiro@socionext.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
paulmck@linux.vnet.ibm.com,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
rdunlap@infradead.org, Shuah Khan <shuah@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)),
yhs@fb.com
Subject: Re: [PATCH 1/2] Provide in-kernel headers for making it easy to extend the kernel
Date: Thu, 7 Feb 2019 17:52:39 -0500 [thread overview]
Message-ID: <20190207175239.0607f5eb@gandalf.local.home> (raw)
In-Reply-To: <20190207211102.154634-1-joel@joelfernandes.org>
On Thu, 7 Feb 2019 16:11:01 -0500
"Joel Fernandes (Google)" <joel@joelfernandes.org> wrote:
> +
> +# Build a list of in-kernel headers for building kernel modules
> +# Any other files will be stored in IKH_EXTRA variable.
> +ikh_file_list := include/
> +ikh_file_list += arch/$(ARCH)/Makefile
> +ikh_file_list += arch/$(ARCH)/include/
> +ikh_file_list += $(IKH_EXTRA)
> +ikh_file_list += scripts/
> +ikh_file_list += Makefile
> +ikh_file_list += Module.symvers
> +ifeq ($(CONFIG_STACK_VALIDATION), y)
> +ikh_file_list += $(objtree)/tools/objtool/objtool
> +endif
> +
> +$(obj)/kheaders.o: $(obj)/kheaders_data.h
> +
> +targets += kheaders_data.txz
> +
> +quiet_cmd_genikh = GEN $(obj)/kheaders_data.txz
> +cmd_genikh = $(srctree)/scripts/gen_ikh_data.sh $@ $^ >/dev/null 2>&1
> +$(obj)/kheaders_data.txz: $(ikh_file_list) FORCE
> + $(call cmd,genikh)
> +
> +filechk_ikheadersxz = (echo "static const char kernel_headers_data[] __used = KH_MAGIC_START"; cat $< | scripts/bin2c; echo "KH_MAGIC_END;")
> +
> +targets += kheaders_data.h
> +$(obj)/kheaders_data.h: $(obj)/kheaders_data.txz FORCE
> + $(call filechk,ikheadersxz)
> diff --git a/scripts/gen_ikh_data.sh b/scripts/gen_ikh_data.sh
> new file mode 100755
> index 000000000000..609196b5cea2
> --- /dev/null
> +++ b/scripts/gen_ikh_data.sh
> @@ -0,0 +1,19 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +
> +spath="$(dirname "$(readlink -f "$0")")"
> +
> +rm -rf $1.tmp
> +mkdir $1.tmp
> +
> +for f in "${@:2}";
> + do find "$f" ! -name "*.c" ! -name "*.o" ! -name "*.cmd" ! -name ".*";
I wonder if it is a good idea to pick all files in the directories
defined in ikh_file_list, and not just explicitly list what we want,
with a '*.h' and such?
> +done | cpio -pd $1.tmp
> +
> +for f in $(find $1.tmp); do
> + $spath/strip-comments.pl $f
> +done
> +
> +tar -Jcf $1 -C $1.tmp/ . > /dev/null
> +
> +rm -rf $1.tmp
> diff --git a/scripts/strip-comments.pl b/scripts/strip-comments.pl
> new file mode 100755
> index 000000000000..f8ada87c5802
> --- /dev/null
> +++ b/scripts/strip-comments.pl
> @@ -0,0 +1,8 @@
> +#!/usr/bin/perl -pi
> +# SPDX-License-Identifier: GPL-2.0
> +
> +# This script removes /**/ comments from a file, unless such comments
> +# contain "SPDX". It is used when building compressed in-kernel headers.
> +
> +BEGIN {undef $/;}
> +s/\/\*((?!SPDX).)*?\*\///smg;
Hmm, I'm also wondering if we could us the C pre-processor for the
stripping of everything from the header file. We would then even get
the header files only having what is necessary for the running kernel.
-- Steve
next prev parent reply other threads:[~2019-02-07 22:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-07 21:11 [PATCH 1/2] Provide in-kernel headers for making it easy to extend the kernel Joel Fernandes (Google)
2019-02-07 21:11 ` [PATCH 2/2] Add selftests for module build using in-kernel headers Joel Fernandes (Google)
2019-02-07 22:52 ` Steven Rostedt [this message]
2019-02-07 23:39 ` [PATCH 1/2] Provide in-kernel headers for making it easy to extend the kernel Joel Fernandes
2019-02-07 23:50 ` Steven Rostedt
2019-02-08 0:11 ` Joel Fernandes
2019-02-11 1:39 ` Masahiro Yamada
2019-02-11 14:37 ` Joel Fernandes
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=20190207175239.0607f5eb@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=alexandre.torgue@st.com \
--cc=ast@kernel.org \
--cc=atishp04@gmail.com \
--cc=corbet@lwn.net \
--cc=dan.j.williams@intel.com \
--cc=dancol@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=joel@joelfernandes.org \
--cc=karim.yaghmour@opersys.com \
--cc=keescook@chromium.org \
--cc=kernel-team@android.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux@manojrajarao.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=mingo@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rdunlap@infradead.org \
--cc=shuah@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yamada.masahiro@socionext.com \
--cc=yhs@fb.com \
/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).