linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Masahiro Yamada <yamada.masahiro@socionext.com>,
	linux-kbuild@vger.kernel.org
Cc: Sam Ravnborg <sam@ravnborg.org>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jonathan Corbet <corbet@lwn.net>,
	Michal Marek <michal.lkml@markovi.net>
Subject: Re: [PATCH v2 3/4] kbuild: support header-test-pattern-y
Date: Thu, 27 Jun 2019 14:28:26 +0300	[thread overview]
Message-ID: <871rzfqnc5.fsf@intel.com> (raw)
In-Reply-To: <20190627014617.600-4-yamada.masahiro@socionext.com>

On Thu, 27 Jun 2019, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> In my view, most of headers can be self-contained. So, it would be
> tedious to add every header to header-test-y explicitly. We usually
> end up with "all headers with some exceptions".
>
> There are two types in exceptions:
>
> [1] headers that are never compiled as standalone units
>
>   For examples, include/linux/compiler-gcc.h is not intended to be
>   included directly. We should always exclude such ones.
>
> [2] headers that are conditionally compiled as standalone units
>
>   Some headers can be compiled only for particular architectures.
>   For example, include/linux/arm-cci.h can be compiled only for
>   arm/arm64 because it requires <asm/arm-cci.h> to exist.
>   Clang can compile include/soc/nps/mtm.h only for arc because
>   it contains an arch-specific register in inline assembler.
>
> For [2], we can write Makefile like this:
>
>   header-test-$(CONFIG_ARM) += linux/arm-cci.h
>
> The new syntax header-test-pattern-y will be useful to specify
> "the rest".
>
> The typical usage is like this:
>
>   header-test-pattern-y += */*.h
>
> This adds all the headers in sub-directories to the test coverage,
> but headers added to header-test- are excluded. In this regards,
> header-test-pattern-y behaves like a weaker variant of header-test-y.
>
> Caveat:
> The patterns in header-test-pattern-y are prefixed with $(srctree)/$(src)/
> but not $(objtree)/$(obj)/. Stale generated patterns are often left over.
> For example, you will have ones when you traverse the git history for
> 'git bisect' without cleaning. If a wildcard is used for generated
> headers, it may match to stale headers.
>
> If you really want to compile-test generated headers, I recommend to
> add them to header-test-y explicitly. One pitfall is $(srctree)/$(src)/
> and $(objtree)/$(obj)/ point to the same directory for in-tree building.
> So, header-test-pattern-y should be used with care. It can potentially
> match to generated headers, which may be stale and fail to compile.
>
> Caveat2:
> You could use wildcard for header-test-. For example,
>
>   header-test- += asm-generic/%
>
> ... will exclude headers in asm-generic directory. Unfortunately, the
> wildcard character is '%' instead of '*' because this is evaluated by
> $(filter-out ...) whereas header-test-pattern-y is evaluated by
> $(wildcard ...). This is a kludge, but seems useful in some places...
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Awesome! This will let us get rid of our local $(wildcard) hacks.

Tested-by: Jani Nikula <jani.nikula@intel.com>

> ---
>
> Changes in v2:
>   - New patch
>
>  Documentation/kbuild/makefiles.txt | 10 ++++++++++
>  scripts/Makefile.lib               | 10 ++++++++++
>  2 files changed, 20 insertions(+)
>
> diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
> index 5080fec34609..b817e6cefb77 100644
> --- a/Documentation/kbuild/makefiles.txt
> +++ b/Documentation/kbuild/makefiles.txt
> @@ -1025,6 +1025,16 @@ When kbuild executes, the following steps are followed (roughly):
>  	i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled,
>  	this builds them as part of extra-y.
>  
> +    header-test-pattern-y
> +
> +	This works as a weaker version of header-test-y, and accepts wildcard
> +	patterns. The typical usage is:
> +
> +		  header-test-pattern-y += *.h
> +
> +	This specifies all the files that matches to '*.h' in the current
> +	directory, but the files in 'header-test-' are excluded.
> +
>  --- 6.7 Commands useful for building a boot image
>  
>  	Kbuild provides a few macros that are useful when building a
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 55ae1ec65342..54444933bbab 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -67,6 +67,16 @@ extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-))
>  endif
>  
>  # Test self-contained headers
> +
> +# Wildcard searches in $(srctree)/$(src)/, but not in $(objtree)/$(obj)/.
> +# Stale generated headers are often left over, so wildcard matching should
> +# be avoided. Please notice $(srctree)/$(src)/ and $(objtree)/$(obj) point
> +# to the same location for in-tree building.
> +header-test-y	+= $(filter-out $(header-test-), \
> +		$(patsubst $(srctree)/$(src)/%, %, \
> +		$(wildcard $(addprefix $(srctree)/$(src)/, \
> +		$(header-test-pattern-y)))))
> +
>  extra-$(CONFIG_HEADER_TEST) += $(addsuffix .s, $(header-test-y))
>  
>  # Add subdir path

-- 
Jani Nikula, Intel Open Source Graphics Center

  reply	other threads:[~2019-06-27 11:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-27  1:46 [PATCH v2 0/4] Compile-test UAPI and kernel headers Masahiro Yamada
2019-06-27  1:46 ` [PATCH v2 2/4] kbuild: do not create wrappers for header-test-y Masahiro Yamada
2019-06-27 11:25   ` Jani Nikula
2019-06-27  1:46 ` [PATCH v2 3/4] kbuild: support header-test-pattern-y Masahiro Yamada
2019-06-27 11:28   ` Jani Nikula [this message]
2019-06-27  3:12 ` [PATCH v2 0/4] Compile-test UAPI and kernel headers Masahiro Yamada
2019-06-27 11:39 ` Jani Nikula
2019-06-27 16:42   ` 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=871rzfqnc5.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=sam@ravnborg.org \
    --cc=yamada.masahiro@socionext.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).