commit:     14d75ac4afef46923bddbd0fe0b36c549b8b7bc0
Author:     Mike Pagano <mpagano <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 27 15:51:07 2021 +0000
Commit:     Mike Pagano <mpagano <AT> gentoo <DOT> org>
CommitDate: Wed Oct 27 15:51:07 2021 +0000
URL:        https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=14d75ac4

Fix how gcc version detectioned to make visible CONFIG_GCC_PLUGINS

Thanks to Kerin Millar.

Bug: https://bugs.gentoo.org/814200

Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>

 0000_README                         |  4 ++
 2910_fix-gcc-detection-method.patch | 92 +++++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+)

diff --git a/0000_README b/0000_README
index 0d389ec..e008863 100644
--- a/0000_README
+++ b/0000_README
@@ -687,6 +687,10 @@ Patch:  2600_enable-key-swapping-for-apple-mac.patch
 From:   https://github.com/free5lot/hid-apple-patched
 Desc:   This hid-apple patch enables swapping of the FN and left Control keys 
and some additional on some apple keyboards. See bug #622902
 
+Patch:  2910_fix-gcc-detection-method.patch
+From:   https://bugs.gentoo.org/814200
+Desc:   Fix how gcc version is detected to make visible CONFIG_GCC_PLUGINS. 
Thanks to Kerin Millar.
+
 Patch:  2920_sign-file-patch-for-libressl.patch
 From:   https://bugs.gentoo.org/717166
 Desc:   sign-file: full functionality with modern LibreSSL

diff --git a/2910_fix-gcc-detection-method.patch 
b/2910_fix-gcc-detection-method.patch
new file mode 100644
index 0000000..d7ed901
--- /dev/null
+++ b/2910_fix-gcc-detection-method.patch
@@ -0,0 +1,92 @@
+--- a/scripts/gcc-plugin.sh    2021-09-23 10:18:55.315793245 -0400
++++ /dev/null  2021-10-27 08:48:41.750968153 -0400
+@@ -1,66 +0,0 @@
+-#!/bin/sh
+-# SPDX-License-Identifier: GPL-2.0
+-srctree=$(dirname "$0")
+-
+-SHOW_ERROR=
+-if [ "$1" = "--show-error" ] ; then
+-      SHOW_ERROR=1
+-      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 <<EOF
+-#include "gcc-common.h"
+-#if BUILDING_GCC_VERSION >= 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
+-
+-# 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 <<EOF
+-#include "gcc-common.h"
+-class test {
+-public:
+-      int test;
+-} test = {
+-      .test = 1
+-};
+-EOF
+-)
+-
+-if [ $? -eq 0 ]
+-then
+-      echo "$2"
+-      exit 0
+-fi
+-
+-if [ -n "$SHOW_ERROR" ] ; then
+-      echo "${plugincc}" >&2
+-fi
+-exit 1
+--- a/scripts/gcc-plugins/Kconfig      2021-09-23 10:15:50.898216868 -0400
++++ b/scripts/gcc-plugins/Kconfig      2021-10-27 11:44:35.700620974 -0400
+@@ -17,7 +17,8 @@ config HAVE_GCC_PLUGINS
+ menuconfig GCC_PLUGINS
+       bool "GCC plugins"
+       depends on HAVE_GCC_PLUGINS
+-      depends on PLUGIN_HOSTCC != ""
++      depends on CC_IS_GCC
++      depends on $(success,test -e $(shell,$(CC) 
-print-file-name=plugin)/include/plugin-version.h)
+       default y
+       help
+         GCC plugins are loadable modules that provide extra features to the
+--- a/scripts/gcc-plugins/Makefile     2021-10-27 10:58:03.960272437 -0400
++++ b/scripts/gcc-plugins/Makefile     2021-10-27 10:59:37.313786319 -0400
+@@ -8,7 +8,7 @@ ifeq ($(PLUGINCC),$(HOSTCC))
+   export HOST_EXTRACFLAGS
+ else
+   HOSTLIBS := hostcxxlibs
+-  HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu++98 
-fno-rtti
++  HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu++11 
-fno-rtti
+   HOST_EXTRACXXFLAGS += -fno-exceptions -fasynchronous-unwind-tables -ggdb
+   HOST_EXTRACXXFLAGS += -Wno-narrowing -Wno-unused-variable
+   HOST_EXTRACXXFLAGS += -Wno-format-diag

Reply via email to