1 From e6a71160cc145e18ab45195abf89884112e02dfb Mon Sep 17 00:00:00 2001
2 From: Kees Cook <keescook@chromium.org>
3 Date: Wed, 18 Jan 2023 12:21:35 -0800
4 Subject: gcc-plugins: Reorganize gimple includes for GCC 13
6 The gimple-iterator.h header must be included before gimple-fold.h
7 starting with GCC 13. Reorganize gimple headers to work for all GCC
10 Reported-by: Palmer Dabbelt <palmer@rivosinc.com>
11 Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
12 Link: https://lore.kernel.org/all/20230113173033.4380-1-palmer@rivosinc.com/
13 Cc: linux-hardening@vger.kernel.org
14 Signed-off-by: Kees Cook <keescook@chromium.org>
16 scripts/gcc-plugins/gcc-common.h | 4 ++--
17 1 file changed, 2 insertions(+), 2 deletions(-)
19 diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
20 index 9a1895747b153..84c730da36dd3 100644
21 --- a/scripts/gcc-plugins/gcc-common.h
22 +++ b/scripts/gcc-plugins/gcc-common.h
25 #include "stor-layout.h"
26 #include "internal-fn.h"
28 #include "gimple-expr.h"
29 +#include "gimple-iterator.h"
30 #include "gimple-fold.h"
32 #include "tree-ssa-alias.h"
39 #if BUILDING_GCC_VERSION >= 4009
40 #include "tree-ssa-operands.h"
41 #include "tree-phinodes.h"
43 -#include "gimple-iterator.h"
44 #include "gimple-ssa.h"
45 #include "ssa-iterators.h"
50 From 5a6b64adc18d9adfb497a529ff004d59b6df151f Mon Sep 17 00:00:00 2001
51 From: Sam James <sam@gentoo.org>
52 Date: Wed, 1 Feb 2023 23:00:09 +0000
53 Subject: gcc-plugins: drop -std=gnu++11 to fix GCC 13 build
55 The latest GCC 13 snapshot (13.0.1 20230129) gives the following:
57 cc1: error: cannot load plugin ./scripts/gcc-plugins/randomize_layout_plugin.so
58 :./scripts/gcc-plugins/randomize_layout_plugin.so: undefined symbol: tree_code_type
61 This ends up being because of https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=b0241ce6e37031
62 upstream in GCC which changes the visibility of some types used by the kernel's
63 plugin infrastructure like tree_code_type.
65 After discussion with the GCC folks, we found that the kernel needs to be building
66 plugins with the same flags used to build GCC - and GCC defaults to gnu++17
67 right now. The minimum GCC version needed to build the kernel is GCC 5.1
68 and GCC 5.1 already defaults to gnu++14 anyway, so just drop the flag, as
69 all GCCs that could be used to build GCC already default to an acceptable
70 version which was >= the version we forced via flags until now.
72 Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108634
73 Signed-off-by: Sam James <sam@gentoo.org>
74 Signed-off-by: Kees Cook <keescook@chromium.org>
75 Link: https://lore.kernel.org/r/20230201230009.2252783-1-sam@gentoo.org
77 scripts/gcc-plugins/Makefile | 2 +-
78 1 file changed, 1 insertion(+), 1 deletion(-)
80 diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile
81 index b34d11e226366..320afd3cf8e82 100644
82 --- a/scripts/gcc-plugins/Makefile
83 +++ b/scripts/gcc-plugins/Makefile
85 export HOST_EXTRACFLAGS
87 HOSTLIBS := hostcxxlibs
88 - HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu++98 -fno-rtti
89 + HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -fno-rtti
90 HOST_EXTRACXXFLAGS += -fno-exceptions -fasynchronous-unwind-tables -ggdb
91 HOST_EXTRACXXFLAGS += -Wno-narrowing -Wno-unused-variable
92 HOST_EXTRACXXFLAGS += -Wno-format-diag