LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Michal Marek <michal.lkml@markovi.net>,
intel-gfx@lists.freedesktop.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>
Subject: Re: [Intel-gfx] [RFC 1/3] kbuild: add support for ensuring headers are self-contained
Date: Mon, 20 May 2019 12:20:01 +0300 [thread overview]
Message-ID: <87zhnh8ou6.fsf@intel.com> (raw)
In-Reply-To: <CAK7LNAQv-fm2iV6HW_FM0Fe6hNDeJ25c9CS2SbroSOneoepFMQ@mail.gmail.com>
On Sat, 18 May 2019, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> On Fri, May 17, 2019 at 4:48 AM Jani Nikula <jani.nikula@intel.com> wrote:
>>
>> Sometimes it's useful to be able to explicitly ensure certain headers
>> remain self-contained, i.e. that they are compilable as standalone
>> units, by including and/or forward declaring everything they depend on.
>>
>> Add special target header-test-y where individual Makefiles can add
>> headers to be tested if CONFIG_HEADER_TEST is enabled. This will
>> generate a dummy C file per header that gets built as part of extra-y.
>>
>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>> Cc: Michal Marek <michal.lkml@markovi.net>
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>> Documentation/kbuild/makefiles.txt | 7 +++++++
>> init/Kconfig | 9 +++++++++
>> scripts/Makefile.build | 10 ++++++++++
>> scripts/Makefile.lib | 3 +++
>> 4 files changed, 29 insertions(+)
>>
>> diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
>> index 03c065855eaf..73df58e5ea0c 100644
>> --- a/Documentation/kbuild/makefiles.txt
>> +++ b/Documentation/kbuild/makefiles.txt
>> @@ -1036,6 +1036,13 @@ When kbuild executes, the following steps are followed (roughly):
>> In this example, extra-y is used to list object files that
>> shall be built, but shall not be linked as part of built-in.a.
>>
>> + header-test-y
>> +
>> + header-test-y specifies headers (*.h) in the current directory that
>> + should be compile tested to ensure they are self-contained,
>> + i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled,
>> + this autogenerates dummy sources to include the headers, and builds them
>> + as part of extra-y.
>>
>> --- 6.7 Commands useful for building a boot image
>>
>> diff --git a/init/Kconfig b/init/Kconfig
>> index 4592bf7997c0..d91b157201b1 100644
>> --- a/init/Kconfig
>> +++ b/init/Kconfig
>> @@ -95,6 +95,15 @@ config COMPILE_TEST
>> here. If you are a user/distributor, say N here to exclude useless
>> drivers to be distributed.
>>
>> +config HEADER_TEST
>> + bool "Compile test headers that should be standalone compilable"
>> + help
>> + Compile test headers listed in header-test-y target to ensure they are
>> + self-contained, i.e. compilable as standalone units.
>> +
>> + If you are a developer or tester and want to ensure the requested
>> + headers are self-contained, say Y here. Otherwise, choose N.
>> +
>> config LOCALVERSION
>> string "Local version - append to kernel release"
>> help
>> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
>> index 76ca30cc4791..4d4bf698467a 100644
>> --- a/scripts/Makefile.build
>> +++ b/scripts/Makefile.build
>> @@ -291,6 +291,16 @@ quiet_cmd_cc_lst_c = MKLST $@
>> $(obj)/%.lst: $(src)/%.c FORCE
>> $(call if_changed_dep,cc_lst_c)
>>
>> +# Dummy C sources for header test (header-test-y target)
>> +# ---------------------------------------------------------------------------
>> +
>> +quiet_cmd_header_test = HDRTEST $@
>> + cmd_header_test = echo "\#include \"$(<F)\"" > $@
>> +
>> +# FIXME: would be nice to be able to limit this implicit rule to header-test-y
>> +$(obj)/%.header_test.c: $(src)/%.h FORCE
>> + $(call if_changed,header_test)
>> +
>> # Compile assembler sources (.S)
>> # ---------------------------------------------------------------------------
>>
>> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
>> index 8a1f64f17740..c2839de06485 100644
>> --- a/scripts/Makefile.lib
>> +++ b/scripts/Makefile.lib
>> @@ -66,6 +66,9 @@ extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y))
>> extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-))
>> endif
>>
>> +# Test self-contained headers
>> +extra-$(CONFIG_HEADER_TEST) += $(patsubst %.h,%.header_test.o,$(header-test-y))
>> +
>> # Add subdir path
>>
>> extra-y := $(addprefix $(obj)/,$(extra-y))
>> --
>> 2.20.1
>>
>
>
> Thanks, probably we should do this.
>
> At least, this check will be useful
> for uapi headers since the kernel does not
> test the self-containedness of
> exported headers, (then turned out be problematic
> later in user-space).
>
> I will take a little time to considier
> how far we can extend the idea about
> "headers should be self-contained".
Thanks! Please let me know if/when you need further action from me, I
won't post new versions until then.
BR,
Jani.
--
Jani Nikula, Intel Open Source Graphics Center
next prev parent reply other threads:[~2019-05-20 9:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-16 19:48 Jani Nikula
2019-05-16 19:48 ` [RFC 2/3] drm/i915: ensure headers remain self-contained Jani Nikula
2019-05-16 19:48 ` [RFC 3/3] DO NOT MERGE: drm/i915: add failing header to header-test-y Jani Nikula
2019-05-17 8:35 ` [RFC 1/3] kbuild: add support for ensuring headers are self-contained Chris Wilson
2019-05-18 5:29 ` Masahiro Yamada
2019-05-18 5:16 ` Masahiro Yamada
2019-05-20 9:20 ` Jani Nikula [this message]
2019-06-03 17:16 ` [Intel-gfx] " Masahiro Yamada
2019-05-24 17:40 ` Sam Ravnborg
2019-06-03 17:05 ` Masahiro Yamada
2019-06-03 17:33 ` Sam Ravnborg
2019-06-04 0:20 ` Masahiro Yamada
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=87zhnh8ou6.fsf@intel.com \
--to=jani.nikula@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.lkml@markovi.net \
--cc=yamada.masahiro@socionext.com \
--subject='Re: [Intel-gfx] [RFC 1/3] kbuild: add support for ensuring headers are self-contained' \
/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
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).