Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp960032imj; Thu, 7 Feb 2019 14:55:19 -0800 (PST) X-Google-Smtp-Source: AHgI3IYarR82p9LJKTL6yqQcB5Zyl03M0rkq3BjElRWaE1OXcf4/WVF0T8rK8Lve2KeaKjV4oTlK X-Received: by 2002:a63:360b:: with SMTP id d11mr6220446pga.156.1549580119896; Thu, 07 Feb 2019 14:55:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549580119; cv=none; d=google.com; s=arc-20160816; b=GjgNuPhTgDM76U7X80PqhwRdS7N6jar9iNh84LWMrUEVjbUH4PM0RXhU2+6EsAzhkk riwMKHYamiZUa9EvXFs7Vq6H4LrRToDqO4UNf97V/GWOKrFFT8PefioXjAx99xQjvokV bcpTVjbVG3IfyZ8okBqsLEPF17717I6OWFIDx5qqpBV059n6wi9sGlmjKSJurHhnHl7q Nfl4uwMDlMS165VOJAplTBL1BMLmGZwyOqxbqifE8SwzUzKkQRyF/BUs4ua65FjtI9t/ fWr9zf5u/PzH3rWl/EIj3X0mr2vlRvUTVFn6YkOZqZxylBGsfcZJiVZiew6Qn3zsEFaB 6M8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=ZBrMHOFxr0oGodEPgQjGax8mwwYgGpJkUId3iMK0w2I=; b=KTjiYl+jfk0QNLiFHhLk0Si5eAgoI7dV1+GQr4PdkapJ0Rt9UTnvpM+s9YJKstb/Ye T4PqES/+AS/onoynOyKAudsdyIHqirv/5qh8nFDd2AumsZHNHRAbJJk6aLkldQDK7aPO fpmmJCuN87DQh7vd/t4EGdxzSBneyZRybb43RHH72ACHN6JbUscTy7RfCSMFBTcKFOiZ vhXjXwiwukYTwMJiRX4ZyLYKsermXKYHbFFl/GO2aW8p/D4FQvXA2fAUi30mbsuBtjFf FpYy+j/2IzAJchV6D1Zan2jKqOuCPwdGHaJdrcUD5w2t65AHRY5PuqmddX6llRuToDKV O6XA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 187si274284pfv.238.2019.02.07.14.55.04; Thu, 07 Feb 2019 14:55:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727041AbfBGWwp (ORCPT + 99 others); Thu, 7 Feb 2019 17:52:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:51124 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726622AbfBGWwo (ORCPT ); Thu, 7 Feb 2019 17:52:44 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 726AC21721; Thu, 7 Feb 2019 22:52:41 +0000 (UTC) Date: Thu, 7 Feb 2019 17:52:39 -0500 From: Steven Rostedt To: "Joel Fernandes (Google)" Cc: linux-kernel@vger.kernel.org, Alexandre Torgue , Andrew Morton , ast@kernel.org, atishp04@gmail.com, dancol@google.com, Dan Williams , gregkh@linuxfoundation.org, Ingo Molnar , Jonathan Corbet , karim.yaghmour@opersys.com, Kees Cook , kernel-team@android.com, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Manoj Rao , Masahiro Yamada , Mathieu Desnoyers , Maxime Coquelin , paulmck@linux.vnet.ibm.com, "Peter Zijlstra (Intel)" , rdunlap@infradead.org, Shuah Khan , Thomas Gleixner , 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 Message-ID: <20190207175239.0607f5eb@gandalf.local.home> In-Reply-To: <20190207211102.154634-1-joel@joelfernandes.org> References: <20190207211102.154634-1-joel@joelfernandes.org> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 7 Feb 2019 16:11:01 -0500 "Joel Fernandes (Google)" 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