2020-12-26 18:28:16

by Valdis Klētnieks

[permalink] [raw]
Subject: [PATCH] gcc-plugins: fix gcc 11 indigestion with plugins...

Fedora Rawhide has started including gcc 11,and the g++ compiler
throws a wobbly when it hits scripts/gcc-plugins:

HOSTCXX scripts/gcc-plugins/latent_entropy_plugin.so
In file included from /usr/include/c++/11/type_traits:35,
from /usr/lib/gcc/x86_64-redhat-linux/11/plugin/include/system.h:244,
from /usr/lib/gcc/x86_64-redhat-linux/11/plugin/include/gcc-plugin.h:28,
from scripts/gcc-plugins/gcc-common.h:7,
from scripts/gcc-plugins/latent_entropy_plugin.c:78:
/usr/include/c++/11/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO
C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
32 | #error This file requires compiler and library support \

In fact, it works just fine with c++11, which has been in gcc since 4.8,
and we now require 4.9 as a minimum.

Signed-off-by: Valdis Kletnieks <[email protected]>

diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile
index d66949bfeba4..b5487cce69e8 100644
--- a/scripts/gcc-plugins/Makefile
+++ b/scripts/gcc-plugins/Makefile
@@ -22,9 +22,9 @@ always-y += $(GCC_PLUGIN)
GCC_PLUGINS_DIR = $(shell $(CC) -print-file-name=plugin)

plugin_cxxflags = -Wp,-MMD,$(depfile) $(KBUILD_HOSTCXXFLAGS) -fPIC \
- -I $(GCC_PLUGINS_DIR)/include -I $(obj) -std=gnu++98 \
+ -I $(GCC_PLUGINS_DIR)/include -I $(obj) -std=gnu++11 \
-fno-rtti -fno-exceptions -fasynchronous-unwind-tables \
- -ggdb -Wno-narrowing -Wno-unused-variable -Wno-c++11-compat \
+ -ggdb -Wno-narrowing -Wno-unused-variable \
-Wno-format-diag

plugin_ldflags = -shared



Attachments:
(No filename) (849.00 B)

2021-01-05 15:30:07

by Josh Poimboeuf

[permalink] [raw]
Subject: Re: [PATCH] gcc-plugins: fix gcc 11 indigestion with plugins...

On Sat, Dec 26, 2020 at 01:21:58PM -0500, Valdis Klētnieks wrote:
> Fedora Rawhide has started including gcc 11,and the g++ compiler
> throws a wobbly when it hits scripts/gcc-plugins:
>
> HOSTCXX scripts/gcc-plugins/latent_entropy_plugin.so
> In file included from /usr/include/c++/11/type_traits:35,
> from /usr/lib/gcc/x86_64-redhat-linux/11/plugin/include/system.h:244,
> from /usr/lib/gcc/x86_64-redhat-linux/11/plugin/include/gcc-plugin.h:28,
> from scripts/gcc-plugins/gcc-common.h:7,
> from scripts/gcc-plugins/latent_entropy_plugin.c:78:
> /usr/include/c++/11/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO
> C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
> 32 | #error This file requires compiler and library support \
>
> In fact, it works just fine with c++11, which has been in gcc since 4.8,
> and we now require 4.9 as a minimum.
>
> Signed-off-by: Valdis Kletnieks <[email protected]>

I'm also needing this.

Acked-by: Josh Poimboeuf <[email protected]>

--
Josh

2021-01-06 23:12:26

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH] gcc-plugins: fix gcc 11 indigestion with plugins...

On Sat, 26 Dec 2020 13:21:58 -0500, Valdis Klētnieks wrote:
> Fedora Rawhide has started including gcc 11,and the g++ compiler
> throws a wobbly when it hits scripts/gcc-plugins:
>
> HOSTCXX scripts/gcc-plugins/latent_entropy_plugin.so
> In file included from /usr/include/c++/11/type_traits:35,
> from /usr/lib/gcc/x86_64-redhat-linux/11/plugin/include/system.h:244,
> from /usr/lib/gcc/x86_64-redhat-linux/11/plugin/include/gcc-plugin.h:28,
> from scripts/gcc-plugins/gcc-common.h:7,
> from scripts/gcc-plugins/latent_entropy_plugin.c:78:
> /usr/include/c++/11/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO
> C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
> 32 | #error This file requires compiler and library support \
>
> [...]

Applied to for-linus/gcc-plugins, thanks!

[1/1] gcc-plugins: fix gcc 11 indigestion with plugins...
https://git.kernel.org/kees/c/67a5a6801305

--
Kees Cook

2021-01-11 09:50:44

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] gcc-plugins: fix gcc 11 indigestion with plugins...

Hi Kees, Valdis,

On Thu, Jan 7, 2021 at 12:11 AM Kees Cook <[email protected]> wrote:
> On Sat, 26 Dec 2020 13:21:58 -0500, Valdis Klētnieks wrote:
> > Fedora Rawhide has started including gcc 11,and the g++ compiler
> > throws a wobbly when it hits scripts/gcc-plugins:
> >
> > HOSTCXX scripts/gcc-plugins/latent_entropy_plugin.so
> > In file included from /usr/include/c++/11/type_traits:35,
> > from /usr/lib/gcc/x86_64-redhat-linux/11/plugin/include/system.h:244,
> > from /usr/lib/gcc/x86_64-redhat-linux/11/plugin/include/gcc-plugin.h:28,
> > from scripts/gcc-plugins/gcc-common.h:7,
> > from scripts/gcc-plugins/latent_entropy_plugin.c:78:
> > /usr/include/c++/11/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO
> > C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
> > 32 | #error This file requires compiler and library support \
> >
> > [...]
>
> Applied to for-linus/gcc-plugins, thanks!
>
> [1/1] gcc-plugins: fix gcc 11 indigestion with plugins...
> https://git.kernel.org/kees/c/67a5a6801305

I guess this is the cause of the new "warning: invalid suffix on
literal; C++11 requires a space between literal and string macro
[-Wliteral-suffix]" with gcc 4.9 or 5.4?

https://lore.kernel.org/lkml/[email protected]

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2021-01-11 11:00:27

by Valdis Klētnieks

[permalink] [raw]
Subject: Re: [PATCH] gcc-plugins: fix gcc 11 indigestion with plugins...

On Mon, 11 Jan 2021 10:47:23 +0100, Geert Uytterhoeven said:

> I guess this is the cause of the new "warning: invalid suffix on
> literal; C++11 requires a space between literal and string macro
> [-Wliteral-suffix]" with gcc 4.9 or 5.4?

Well, we fixed a #error, and picked up a warning. That's progress. ;)

It's probably related. I'm just having a hard time understanding why 4.9 and 5.4
whine about the lack of a space, while 8.3 and 11 didn't complain...

I'll see if I can cook up a patch that newer gcc are still happy with. You able
to easily test with 4.9 or 5.4?




Attachments:
(No filename) (849.00 B)

2021-01-11 13:08:12

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] gcc-plugins: fix gcc 11 indigestion with plugins...

Hi Valdis,

On Mon, Jan 11, 2021 at 11:57 AM Valdis Klētnieks
<[email protected]> wrote:
> On Mon, 11 Jan 2021 10:47:23 +0100, Geert Uytterhoeven said:
> > I guess this is the cause of the new "warning: invalid suffix on
> > literal; C++11 requires a space between literal and string macro
> > [-Wliteral-suffix]" with gcc 4.9 or 5.4?
>
> Well, we fixed a #error, and picked up a warning. That's progress. ;)
>
> It's probably related. I'm just having a hard time understanding why 4.9 and 5.4
> whine about the lack of a space, while 8.3 and 11 didn't complain...
>
> I'll see if I can cook up a patch that newer gcc are still happy with. You able
> to easily test with 4.9 or 5.4?

No, I don't have 4.9 or 5.4 cross-compilers anymore.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2021-01-12 00:40:44

by Valdis Klētnieks

[permalink] [raw]
Subject: Re: [PATCH] gcc-plugins: fix gcc 11 indigestion with plugins...

On Mon, 11 Jan 2021 05:56:59 -0500, I said:

> > It's probably related. I'm just having a hard time understanding why 4.9 and 5.4
> > whine about the lack of a space, while 8.3 and 11 didn't complain...

So after more digging, at least some clarity has surfaced.

It looks like it's not a kernel source tree issue, it's a g++ issue fixed in g++ 6 and later.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69959

And it looks like there was an intent to backport it to 4.9 and 5.4:
https://gcc.gnu.org/legacy-ml/gcc-patches/2016-02/msg01409.html

The bugtracker doesn't show an equivalent for 69959 being closed against 4.9.x or 5.[56],

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63254 has a patch for one of the
gcc-supplied files that tosses the warning, but that way lies madness...

Not sure what we want to do here - the main alternatives I see are:

Tell people still using 4.9/5.4 to either live with the warning or upgrade to 6 or later

Make the flag a variable and pass either -std=gnu++98 or -std=gnu++11
depending on the output of 'g++ --version'

What say the peanut gallery?


Attachments:
(No filename) (849.00 B)

2021-01-12 06:02:56

by Josh Poimboeuf

[permalink] [raw]
Subject: Re: [PATCH] gcc-plugins: fix gcc 11 indigestion with plugins...

On Mon, Jan 11, 2021 at 07:31:17AM -0500, Valdis Klētnieks wrote:
> On Mon, 11 Jan 2021 05:56:59 -0500, I said:
>
> > > It's probably related. I'm just having a hard time understanding why 4.9 and 5.4
> > > whine about the lack of a space, while 8.3 and 11 didn't complain...
>
> So after more digging, at least some clarity has surfaced.
>
> It looks like it's not a kernel source tree issue, it's a g++ issue fixed in g++ 6 and later.
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69959
>
> And it looks like there was an intent to backport it to 4.9 and 5.4:
> https://gcc.gnu.org/legacy-ml/gcc-patches/2016-02/msg01409.html
>
> The bugtracker doesn't show an equivalent for 69959 being closed against 4.9.x or 5.[56],
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63254 has a patch for one of the
> gcc-supplied files that tosses the warning, but that way lies madness...
>
> Not sure what we want to do here - the main alternatives I see are:
>
> Tell people still using 4.9/5.4 to either live with the warning or upgrade to 6 or later
>
> Make the flag a variable and pass either -std=gnu++98 or -std=gnu++11
> depending on the output of 'g++ --version'
>
> What say the peanut gallery?

I think putting the flag in a variable (based on call cc-ifversion)
should be easy enough, then we can put this little saga behind us and
pretend it never happened :-)

--
Josh