From patchwork Tue Mar 27 05:29:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 132445 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp4654439ljb; Mon, 26 Mar 2018 22:33:42 -0700 (PDT) X-Google-Smtp-Source: AG47ELskXCF35GBJfosCG0k+2u8oytjxlz3eXKhNPqqXUmu8jlwnVXgcP/0eDfe5N9famXnRUdk5 X-Received: by 2002:a17:902:5409:: with SMTP id d9-v6mr31826944pli.176.1522128822285; Mon, 26 Mar 2018 22:33:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522128822; cv=none; d=google.com; s=arc-20160816; b=x5dBAHNG2tXqjhz7vUFqnT8W3RPPXskZ+PgjbdAjw1gOYzH72lE9OU9ZPlGFBypsyQ CzJWurlYhc0jablrRDGaRor0jcBZS6n/vmVMmUD80VmduCWSsVwilYXqytnIi095yNrS 620cZjkzz5sKEPZ5TG20FiTjhEq7JEWz46ZoB2tiGlrqRsQy5wlMnl7Jvplyza2TMnXS 9WqtfKyVTK6TZdgY7s4H6OZr9neaLAGLE6gTVp93/0uKQ2TPLLX9Nh9THtwPZJyl4yKG 223HhjliKuri+q5kB2fhq94BsFDOAJpg/Pm8ZF4O2WSrx47r23djdlYSNd2RpeSzFY0X GJSg== 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 :arc-authentication-results; bh=J5s1k4WDxvrC/cEZRKsOAIhyqGKMiPt0AQZWKjK7RxU=; b=QvsiSK9ZuYxMBp5K4VRz0mIH2LnGfXvk5S1zTJzmt9yRgboOfTO+vxA6h43vf7HGZH WvdeimHrpkulLnF0tGYY0aSA4109To3hNJy98hwbQZ87N6kqkJhWbRgZHFCr6rsHXjfD GAHgQIH0mmRq8zMnRFXtSn7+nvANUELQ7ElSaDhdge/VwEEhykdsBH0K2E1rTCjUsqr7 l1vQ2lPOUAnOGE/KowYMT/GAT4Rmi6Urz6WG0DZCviMgZ48TdzIdgR4t8kt3zReesl1h 761B7cJi171Lg4r/L++vJ5J3AtS1vMumQux9OihH5ciawwd+vo8kBXTG7mKQpvldZ1RU pSSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=GNX1TWYc; 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 v190si407091pfv.59.2018.03.26.22.33.41; Mon, 26 Mar 2018 22:33:42 -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=GNX1TWYc; 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 S1752496AbeC0Fdi (ORCPT + 28 others); Tue, 27 Mar 2018 01:33:38 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:45037 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751805AbeC0FcM (ORCPT ); Tue, 27 Mar 2018 01:32:12 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id w2R5TaM4011947; Tue, 27 Mar 2018 14:30:00 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com w2R5TaM4011947 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1522128601; bh=J5s1k4WDxvrC/cEZRKsOAIhyqGKMiPt0AQZWKjK7RxU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GNX1TWYcTFNOeF9x4OR0lIO7zYxyiH6YKKu6+aIBlFLTqLskst8NA/JqwzkYGh02V eCvPoSFbzduPPOUq4DaLjLPd5utMTFV2Lwm0ql/tIiUkWcwA5Vsv342ZK9c1mmm2oj SYD+oeIotnTP3CBdlnGfz98QLpDOT9HQvKUDz7gPkKUWEQepdAEI+LyiUxRHpMs0+v dinnYJ9nY+G7nH1ULUWFX31Mx8Oher+IQLybA9kyw5IRNG2MQbQ8IP4C+wsnmFYhTF h5jps7CHTwo/TRt/eF9YpKBgUfvWn4BscWE2gnwc8gRXVSNn1PSxIfM+OkGm0TLwiI XmWx/x5cNXr7w== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Linus Torvalds , Arnd Bergmann , Ulf Magnusson , Kees Cook , Thomas Gleixner , Greg Kroah-Hartman , Randy Dunlap , "Luis R . Rodriguez" , Nicolas Pitre , Masahiro Yamada , linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Emese Revfy Subject: [PATCH v2 19/21] gcc-plugins: test GCC plugin support in Kconfig Date: Tue, 27 Mar 2018 14:29:33 +0900 Message-Id: <1522128575-5326-20-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522128575-5326-1-git-send-email-yamada.masahiro@socionext.com> References: <1522128575-5326-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Run scripts/gcc-plugin.sh from Kconfig. Users can enable GCC_PLUGINS only when it is supported. Signed-off-by: Masahiro Yamada --- Changes in v2: None arch/Kconfig | 4 +++ scripts/Makefile.gcc-plugins | 82 ++++++++++++++++---------------------------- scripts/gcc-plugin.sh | 1 - 3 files changed, 33 insertions(+), 54 deletions(-) -- 2.7.4 diff --git a/arch/Kconfig b/arch/Kconfig index b42378d..88cc925 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -407,9 +407,13 @@ config HAVE_GCC_PLUGINS An arch should select this symbol if it supports building with GCC plugins. +config CC_HAS_GCC_PLUGINS + bool + menuconfig GCC_PLUGINS bool "GCC plugins" depends on HAVE_GCC_PLUGINS + depends on $(success $srctree/scripts/gcc-plugin.sh $HOSTCXX $CC) depends on !COMPILE_TEST help GCC plugins are loadable modules that provide extra features to the diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins index 25da4c0..19d0d5b 100644 --- a/scripts/Makefile.gcc-plugins +++ b/scripts/Makefile.gcc-plugins @@ -1,71 +1,47 @@ # SPDX-License-Identifier: GPL-2.0 -ifdef CONFIG_GCC_PLUGINS - PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh $(HOSTCXX) $(CC)) - - SANCOV_PLUGIN := -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so +SANCOV_PLUGIN := -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so - gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) += cyc_complexity_plugin.so +gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) += cyc_complexity_plugin.so - gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += latent_entropy_plugin.so - gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += -DLATENT_ENTROPY_PLUGIN - ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY - DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable - endif +gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += latent_entropy_plugin.so +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += -DLATENT_ENTROPY_PLUGIN +ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY + DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable +endif - ifdef CONFIG_GCC_PLUGIN_SANCOV - ifeq ($(CFLAGS_KCOV),) - # It is needed because of the gcc-plugin.sh and gcc version checks. - gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so +ifdef CONFIG_GCC_PLUGIN_SANCOV + ifeq ($(CFLAGS_KCOV),) + # It is needed because of the gcc-plugin.sh and gcc version checks. + gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so - ifneq ($(PLUGINCC),) - CFLAGS_KCOV := $(SANCOV_PLUGIN) - else - $(warning warning: cannot use CONFIG_KCOV: -fsanitize-coverage=trace-pc is not supported by compiler) - endif - endif + CFLAGS_KCOV := $(SANCOV_PLUGIN) endif +endif - gcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += structleak_plugin.so - gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE) += -fplugin-arg-structleak_plugin-verbose - gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL) += -fplugin-arg-structleak_plugin-byref-all - gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += -DSTRUCTLEAK_PLUGIN - - gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += randomize_layout_plugin.so - gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += -DRANDSTRUCT_PLUGIN - gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE) += -fplugin-arg-randomize_layout_plugin-performance-mode +gcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += structleak_plugin.so +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE) += -fplugin-arg-structleak_plugin-verbose +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL) += -fplugin-arg-structleak_plugin-byref-all +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += -DSTRUCTLEAK_PLUGIN - GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y)) +gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += randomize_layout_plugin.so +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += -DRANDSTRUCT_PLUGIN +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE) += -fplugin-arg-randomize_layout_plugin-performance-mode - export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR - export SANCOV_PLUGIN DISABLE_LATENT_ENTROPY_PLUGIN +GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y)) - ifneq ($(PLUGINCC),) - # SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication. - GCC_PLUGINS_CFLAGS := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGINS_CFLAGS)) - endif +export GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR +export SANCOV_PLUGIN DISABLE_LATENT_ENTROPY_PLUGIN - KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) - GCC_PLUGIN := $(gcc-plugin-y) - GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y) -endif +# SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication. +GCC_PLUGINS_CFLAGS := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGINS_CFLAGS)) -# If plugins aren't supported, abort the build before hard-to-read compiler -# errors start getting spewed by the main build. -PHONY += gcc-plugins-check -gcc-plugins-check: FORCE -ifdef CONFIG_GCC_PLUGINS - ifeq ($(PLUGINCC),) - ifneq ($(GCC_PLUGINS_CFLAGS),) - $(Q)$(srctree)/scripts/gcc-plugin.sh --show-error $(HOSTCXX) $(CC) || true - @echo "Cannot use CONFIG_GCC_PLUGINS: your gcc installation does not support plugins, perhaps the necessary headers are missing?" >&2 && exit 1 - endif - endif -endif - @: +KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) +GCC_PLUGIN := $(gcc-plugin-y) +GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y) # Actually do the build, if requested. PHONY += gcc-plugins -gcc-plugins: scripts_basic gcc-plugins-check +gcc-plugins: scripts_basic ifdef CONFIG_GCC_PLUGINS $(Q)$(MAKE) $(build)=scripts/gcc-plugins endif diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh index 0edbdae..b18c69c 100755 --- a/scripts/gcc-plugin.sh +++ b/scripts/gcc-plugin.sh @@ -24,7 +24,6 @@ EOF if [ $? -eq 0 ] then - echo "$1" exit 0 fi