Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp150752yba; Mon, 20 May 2019 06:31:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8EG1RH6CW6T7Icqxq7mIWESTEpifYQ494cfsjnLADCEwrGQNITiun28qK5b9KqviKZ+FK X-Received: by 2002:aa7:8083:: with SMTP id v3mr16223469pff.135.1558359073342; Mon, 20 May 2019 06:31:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558359073; cv=none; d=google.com; s=arc-20160816; b=UWLzRkRCKhXbKOIU8qI3IH1SUs+XyPK0dNiIz5tQi4/Qop5wyDXCU4woZo28dOGDi9 lCsh6+Qf/fA3CdH35L/zh+FA8nUOjoV1+PFcj5ydkylDelDMNtnz+8qlp5KcEkZZB3AA 1x0E4Z5NeuAQvOq6ziMfu9vg3yAjga7MYuR0NDR1EZ38p9Vl3rHAomajbGkPb6PKp5PF ShWTOertTMtgmm6G4lpjc+StsZWAFaBTecSxDCdYWniiY3EjOcpp4gVlAEbc9r8ONJDP P8rd7IB5X1VetH3kOxbLRV2a5inmYndOiYQHHenvnLf+DTuqwpcsmIQnYSbWA+g2eipn MUMQ== 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=LpNpDcg3eQ9TlRuBR0YejQ2st+adEQ+6PVXdtDPRR3E=; b=07JO+TRR6nU7yZ62c5qJ48HM+sW76dA9KRg03HW3ule9pt2sTYCW0uvwP3XuFeTx9U 3dXeNbBI0kMlQVceJXzM2ubOCOywWvtGTo71UMVCfwQfKFmch7hco1vEvzntfNKmoXBA CjCdJD1l/orsq5pGJtZCjjRYjEv8Jf2K2unjE4/2Az7D8r4GZ3ng93KADxFR/JIpV/Vu aqVCYivArjG7miEKGZOAw/FgPxom7/8p6w5FwimN3NoxSZ9g/2NfFULGfDC7pRNZyWrP 8e++5m7B0E8s/LBt6JyzbXq/xAaDQCpuuSX7vaJLQ17HhhgFRFjtE2ATnreN+OZOydNP Rexw== 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 i1si17048966pgd.404.2019.05.20.06.30.58; Mon, 20 May 2019 06:31:13 -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 S1730918AbfETJQo (ORCPT + 99 others); Mon, 20 May 2019 05:16:44 -0400 Received: from mga17.intel.com ([192.55.52.151]:12516 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730302AbfETJQo (ORCPT ); Mon, 20 May 2019 05:16:44 -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 fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 May 2019 02:16:44 -0700 X-ExtLoop1: 1 Received: from jnikula-mobl3.fi.intel.com (HELO localhost) ([10.237.66.150]) by fmsmga001.fm.intel.com with ESMTP; 20 May 2019 02:16:41 -0700 From: Jani Nikula To: Masahiro Yamada Cc: Michal Marek , intel-gfx@lists.freedesktop.org, Linux Kernel Mailing List , Linux Kbuild mailing list Subject: Re: [Intel-gfx] [RFC 1/3] kbuild: add support for ensuring headers are self-contained In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20190516194818.29230-1-jani.nikula@intel.com> Date: Mon, 20 May 2019 12:20:01 +0300 Message-ID: <87zhnh8ou6.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 Sat, 18 May 2019, Masahiro Yamada wrote: > On Fri, May 17, 2019 at 4:48 AM Jani Nikula 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 >> Cc: Masahiro Yamada >> Cc: Michal Marek >> Signed-off-by: Jani Nikula >> --- >> 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 \"$( $@ >> + >> +# 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