Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1953058ybd; Thu, 27 Jun 2019 04:26:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTaTTUskx7UeltGuCVSOmT2MrSmGsV19L6o1nkLD35TOwKslgSoO8pcM6vuIrG0v3rYL/9 X-Received: by 2002:a17:902:1e9:: with SMTP id b96mr4055696plb.277.1561634763339; Thu, 27 Jun 2019 04:26:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561634763; cv=none; d=google.com; s=arc-20160816; b=lNBKqhjlL0XZkzS2qRYJVGyOyhs4qq46/EpMDXr/xcYbLw8HfddJ8dhoBbvd//8cm8 RAXxZWvc358eNbQkri+R7nzvuoOVGOY5E6KjRBPHYEwcjkH2WNOzqD5eyXDuDEWkC4/y /0G8VFuegt52pPNJECzUdFY9DOicpFYtdfq/NDYNnib9R5L24CVSqHCmBpL7b7H5/vZE h5EBXlSSfBE+jE6E3f7fz6FN5F56lPWStGnNCwAJVBq9OO2vy5KdxI3sc5vtImI3s7mP NWDC3f2OiYyDlkxHBevWJ4pyhB/6T7cMgbR6wa4gvIe/AMwxUXyW75VBZ831JbjmsM11 9kJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from; bh=ggVSYCtjpKIwxcLBHraq5tUH35JYUZP/P+ElJvJBGeA=; b=rCC1RXtWG3JYOuWPj7MhLS8zrCFTdzR9Su8+o4vaZV4miBg0gcUWVrtgCX9yPFXvNG 99ZI6lSCLkLKtHnZyXAvJdaRlCSDwNXZDhccU/UtrEkhG0NuJjIAzBFaQecbzBz75605 PlpVpiFLMlyO8H+aIo9Npxa0EsUg33CbLWswmotDG56xZ0plPe/7ZC8THqT1cSzpFcaM cvSA6mCMGPIy7Xsr43d61W+yorfS+RRpXX/oM0xyplrEy8O7sgXsICTM7U9UekJVp7fm v19r6jK55434LtZp9c6+UvF9H+tCo33o+Dr7MOWSrj4JMBXMTlnB7xq+rr+rroiBXMpv CwYg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k2si2153542pgr.162.2019.06.27.04.25.47; Thu, 27 Jun 2019 04:26:03 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726687AbfF0LZn (ORCPT + 99 others); Thu, 27 Jun 2019 07:25:43 -0400 Received: from mga01.intel.com ([192.55.52.88]:50450 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbfF0LZn (ORCPT ); Thu, 27 Jun 2019 07:25:43 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2019 04:25:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,423,1557212400"; d="scan'208";a="183428308" Received: from jnikula-mobl3.fi.intel.com (HELO localhost) ([10.237.66.150]) by fmsmga001.fm.intel.com with ESMTP; 27 Jun 2019 04:25:40 -0700 From: Jani Nikula To: Masahiro Yamada , linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Masahiro Yamada , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Corbet , Michal Marek Subject: Re: [PATCH v2 3/4] kbuild: support header-test-pattern-y In-Reply-To: <20190627014617.600-4-yamada.masahiro@socionext.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20190627014617.600-1-yamada.masahiro@socionext.com> <20190627014617.600-4-yamada.masahiro@socionext.com> Date: Thu, 27 Jun 2019 14:28:26 +0300 Message-ID: <871rzfqnc5.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 27 Jun 2019, Masahiro Yamada 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 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 Awesome! This will let us get rid of our local $(wildcard) hacks. Tested-by: Jani Nikula > --- > > 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