From patchwork Tue Jun 4 10:14:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 165738 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp5638661ili; Tue, 4 Jun 2019 03:16:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqyun8TtktZxNnGiVBHaVLbBS757d/unagP/UYxS/g5dtKwqM2TwGvMRt6eh8Qdq3VcYA5ve X-Received: by 2002:a17:90a:9a8a:: with SMTP id e10mr35793467pjp.109.1559643361126; Tue, 04 Jun 2019 03:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559643361; cv=none; d=google.com; s=arc-20160816; b=ZF4KeuRgNi4lSEMi0qoUbaz6+OXGIW9OvaJAlfIhuxf3bbdpPB5rRzByulplB8WsHc gnRvJdQ1q02GMpTQTdUNS1drsZmN0mFtrA1qz1dPxStKyhVXCMvF1Q31Pk5tN8LC2HIK z816dnXrnOHR5ohzpA9P8Z9rJAa4aiEV06wHR+HAPLFsSezWQ7R3AfNjvIJ5eSJYcAeE bkeCt1wtp57FczkIS/9hekLZSReg+HS6duUZvvvQy5auWtFrvQYTqtxAugDjNstLgwY6 OlYsw9s8Z88g2Fjvin574GsZu6Jr32cF88BoWtw2ywZUk82JS0IQ0PAcAGe6f+lYKCyv C5ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=BnyOCSyE+CGMxDknrCFwRpFRPhO2lG/Y/shoIrbI5AY=; b=YlyL4wLrJNubA6ph6nG/P24mEfvGCdpOZWRbPDq9qcOhCFcqV0NMKBaweqUCzr7XcZ nSq8VanZ40G45Ubh5aieb7ZTJb3iLtXGWP5g5yg1OxiOe8kpMIwJqvYbZSFM4uK6jDYD VsHYMQGi+pKW01xlUuiH10hEr+oltUnDJl0A0sL4awUU+eO2O+MmihbSL3ObNf/7/fdE z92Y4KjJJBzfNhc+/KafPr/blfK5/dUcj+DgfvZxADxaLQzgp+cHQaTnukFdcljhbjQg Enptphde5dac9MJpj9BGI1mkQYO67hs2M2BrkcsWAftvXGGr3M/AficOMYz+ntFE7qjG BGXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b="Z5/reEbe"; 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 s17si1072144pjp.26.2019.06.04.03.16.00; Tue, 04 Jun 2019 03:16:01 -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; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b="Z5/reEbe"; 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 S1727509AbfFDKQA (ORCPT + 30 others); Tue, 4 Jun 2019 06:16:00 -0400 Received: from conuserg-08.nifty.com ([210.131.2.75]:39732 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727110AbfFDKP6 (ORCPT ); Tue, 4 Jun 2019 06:15:58 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id x54AEC7J032511; Tue, 4 Jun 2019 19:14:25 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com x54AEC7J032511 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1559643266; bh=BnyOCSyE+CGMxDknrCFwRpFRPhO2lG/Y/shoIrbI5AY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z5/reEbeHi70KbQtAaW59xxuhoN5CJ6vi0zTzUweFozO6GDDLJBeAGOt0HbBxdGYs kmnBi+G4qTPRlpvorbsKGV4myGYjxSVZF9yHS55WzeKcH13aYk9/cS2UuOW+A6U6aZ /f5GshStK0NXon6uCqj3GinWBcgr25RsSNDCWQXKlTBZ97N9mxffeQvL3rd5WoLYGa izMngyoSmA5ZkdN3JvlFeOHitJlzQ4eiTJeUUasTdqPNdfAWGSchXUCFEgU0oUZFlM SZ9cV3kw61ijSECWdmpFdOLvbCYuVlhModjQaNe7WJUU+jGrifFNh4HnHvf6H1lo40 4S3RsAwPlADag== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Randy Dunlap , Arnd Bergmann , David Howells , Sam Ravnborg , Jani Nikula , Chris Wilson , Masahiro Yamada , Michal Marek , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Corbet Subject: [PATCH 13/15] kbuild: add support for ensuring headers are self-contained Date: Tue, 4 Jun 2019 19:14:07 +0900 Message-Id: <20190604101409.2078-14-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190604101409.2078-1-yamada.masahiro@socionext.com> References: <20190604101409.2078-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jani Nikula 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 Signed-off-by: Masahiro Yamada --- Documentation/kbuild/makefiles.txt | 7 +++++++ init/Kconfig | 9 +++++++++ scripts/Makefile.build | 10 ++++++++++ scripts/Makefile.lib | 3 +++ 4 files changed, 29 insertions(+) -- 2.17.1 Reviewed-by: Sam Ravnborg diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index bac301a73a86..ca4b24ec0399 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -1018,6 +1018,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 36894c9fb420..02d8897b91fb 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -96,6 +96,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 ae9cf740633e..2b4d56483c2e 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -294,6 +294,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 f1f38c8cdc74..60a739a22b9c 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))