From patchwork Fri Feb 16 18:38:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128610 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp864760ljc; Fri, 16 Feb 2018 10:42:14 -0800 (PST) X-Google-Smtp-Source: AH8x22605oIWRvcJ98ethN4+ZdUL2PO3rc8m1dnPXYKNCReNzRitUhArhCOqdjOD1WelvzDhtTQx X-Received: by 10.98.178.218 with SMTP id z87mr6924912pfl.88.1518806534060; Fri, 16 Feb 2018 10:42:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806534; cv=none; d=google.com; s=arc-20160816; b=ANVLsoqctwsoHDa/YgKgAiJBN+SIOL4+Lt2KCliIi/Tlf1noXrqsR9Y5cx72a8HkN8 6uRCoICX/0dT0F+1hSzVPc6/ZmR6PSruU6Lz083zvEfizmCWxsdNXpX0v6sghDybErxV lAvrbGdicM7RuTcS8iUrMVrgobif2GO/Hq0crbr2zWoAU7uRGcPeOKrZZZkeXbIZB6Yy oCRCQ+zS9elcJoOQtEhZnoB5K0PV1xgZrNOoYfgne7hgUiq+DutUD4+oTjjqH2rD1r1N tOA06wuCLa0yepVleQeOR6dHi/2nXAxoT5p/thPyrIYEr464C95AXf1bROdoN2H/Xrxc BUCg== 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=BPc6z7jaBi5hs6EsHJx7v6rdWK5aF1kXWi0zXb2tz0w=; b=EhEWyYPMFrNkSMlBGbKAQWPIsyMMBCfMl627j0sny2Aqbo3HReUJQGPuSodZVuvOQ5 j2XxDT9LI+oSnwwtdeXZ6yxvIVg9GV5NclAOLCifirpxmLIk7g8CNhe96x4WUbi20HHL xuwqDYtpsm8XZ0fgbSJbn/V5FgSbjcDZoeoFznykkIvFP5OanZZyFjnrmWzqyOIphMYL p3oAfcQaXxyjM2PN8C+t3YrLUBe1Ppik7y47bjhN4IqPcGxY8DhBTdolq58O3Mk6OJOs mnrJ9Jitp9VVtQpgAUUQ+TXySSyP4V/ELlFItsBLvU/DSpSn3uAfCCjciHaAUHqDB9DS RPGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=QiTU1ykl; 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 g1-v6si1631408pld.236.2018.02.16.10.42.13; Fri, 16 Feb 2018 10:42:14 -0800 (PST) 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=QiTU1ykl; 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 S1753088AbeBPSly (ORCPT + 28 others); Fri, 16 Feb 2018 13:41:54 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:58376 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753034AbeBPSlv (ORCPT ); Fri, 16 Feb 2018 13:41:51 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTN013418; Sat, 17 Feb 2018 03:39:31 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTN013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806371; bh=BPc6z7jaBi5hs6EsHJx7v6rdWK5aF1kXWi0zXb2tz0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QiTU1yklr9qYYyEZvQiotuZx1gd6GCOp5UNwwd3GAPGHDPoutuEZflnynvOuTAn+B ZN9pZKA4YRnATOA0tuF4qkUKccThrsNoBqWsaKt7f2oWRX9aXF0XdFEgZRxoEbVU4T 2B6gmOxsznRYR8PKz3Mdsa0R0AvkE1rnieg3FQG9Mao7eEcC8NqWKDrlBAEnEiuRBS mddYfzj7Rv96IOHdaXfxZCVTUK4kgHVk87D/Z1/jSLf9kwsz/FjeiQspgBwsgbITKV lTTcQ2INhnLN4JSugXCMMWMnOZWdg+KaRVW+TfILBthdnF7hSTx0GNNFD1fFyQR0tk bUzIIzAIP2UzQ== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org, Emese Revfy Subject: [PATCH 20/23] gcc-plugins: always build plugins with C++ Date: Sat, 17 Feb 2018 03:38:48 +0900 Message-Id: <1518806331-7101-21-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-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 If the target compiler is GCC 4.8 or newer, plugins are compiled with HOSTCXX. Otherwise, gcc-plugin.sh will select HOSTCC or HOSTCXX. To simpily things, let's decide GCC 4.8 is the requirement for GCC pulgins. With this, plugins are always built with HOSTCXX. This is a feature of advanced users, so this requirement whould not be not a big issue. Add 'depends on GCC_VERSION >= 40800' to GCC_PLUGINS, and remove the code that was needed to build plugins with HOSTCC. Signed-off-by: Masahiro Yamada --- arch/Kconfig | 1 + scripts/Makefile.gcc-plugins | 11 +++-------- scripts/gcc-plugin.sh | 38 +++----------------------------------- scripts/gcc-plugins/Makefile | 15 ++++----------- 4 files changed, 11 insertions(+), 54 deletions(-) -- 2.7.4 diff --git a/arch/Kconfig b/arch/Kconfig index 9b7a628..9bd4e1f 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -410,6 +410,7 @@ config HAVE_GCC_PLUGINS menuconfig GCC_PLUGINS bool "GCC plugins" depends on HAVE_GCC_PLUGINS + depends on GCC_VERSION >= 40800 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 b2a95af..b0f9108 100644 --- a/scripts/Makefile.gcc-plugins +++ b/scripts/Makefile.gcc-plugins @@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 ifdef CONFIG_GCC_PLUGINS - __PLUGINCC := $(call cc-ifversion, -ge, 0408, $(HOSTCXX), $(HOSTCC)) - PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)") + PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh $(HOSTCXX) $(CC)) SANCOV_PLUGIN := -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so @@ -65,12 +64,8 @@ ifdef CONFIG_GCC_PLUGINS @echo "Cannot use CONFIG_GCC_PLUGINS: plugin support on gcc <= 5.1 is buggy on powerpc, please upgrade to gcc 5.2 or newer" >&2 && exit 1 endif endif - ifeq ($(call cc-ifversion, -ge, 0405, y), y) - $(Q)$(srctree)/scripts/gcc-plugin.sh --show-error "$(__PLUGINCC)" "$(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 - else - @echo "Cannot use CONFIG_GCC_PLUGINS: your gcc version does not support plugins, you should upgrade it to at least gcc 4.5" >&2 && exit 1 - endif + $(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 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh index d3caefe..0edbdae 100755 --- a/scripts/gcc-plugin.sh +++ b/scripts/gcc-plugin.sh @@ -8,42 +8,10 @@ if [ "$1" = "--show-error" ] ; then shift || true fi -gccplugins_dir=$($3 -print-file-name=plugin) -plugincc=$($1 -E -x c++ - -o /dev/null -I"${srctree}"/gcc-plugins -I"${gccplugins_dir}"/include 2>&1 <= 4008 || defined(ENABLE_BUILD_WITH_CXX) -#warning $2 CXX -#else -#warning $1 CC -#endif -EOF -) - -if [ $? -ne 0 ] -then - if [ -n "$SHOW_ERROR" ] ; then - echo "${plugincc}" >&2 - fi - exit 1 -fi - -case "$plugincc" in - *"$1 CC"*) - echo "$1" - exit 0 - ;; - - *"$2 CXX"*) - # the c++ compiler needs another test, see below - ;; - - *) - exit 1 - ;; -esac +gccplugins_dir=$($2 -print-file-name=plugin) # we need a c++ compiler that supports the designated initializer GNU extension -plugincc=$($2 -c -x c++ -std=gnu++98 - -fsyntax-only -I"${srctree}"/gcc-plugins -I"${gccplugins_dir}"/include 2>&1 <&1 <