Skip to contentSkip to conversation

gcc-plugins: drop -std=gnu++11 to fix GCC 13 build

PATCH Applied Sam James 2 participants 2 messages Feb 1, 2023 – Feb 2, 2023 Gcc plugins

lore
Share & tools
lore

Sam James

author
#0 lore raw

PATCH 1/1 gcc-plugins: drop -std=gnu++11 to fix GCC 13 build

The latest GCC 13 snapshot (13.0.1 20230129) gives the following:

```
cc1: error: cannot load plugin ./scripts/gcc-plugins/randomize_layout_plugin.so
 :./scripts/gcc-plugins/randomize_layout_plugin.so: undefined symbol: tree_code_type
```

This ends up being because of https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=b0241ce6e37031
upstream in GCC which changes the visibility of some types used by the kernel's plugin infrastructure like tree_code_type.

After discussion with the GCC folks, we found that the kernel needs to be building plugins with the same flags used to build GCC - and GCC defaults to gnu++17 right now. The minimum GCC version needed to build the kernel is GCC 5.1 and GCC 5.1 already defaults to gnu++14 anyway, so just drop the flag, as all GCCs that could be used to build GCC already default to an acceptable version which was >= the version we forced via flags until now.

---
 scripts/gcc-plugins/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gcc-plugins/Makefile +1 -1
index b34d11e22636..320afd3cf8e8 100644
@@ -29,7 +29,7 @@ GCC_PLUGINS_DIR = $(shell $(CC) -print-file-name=plugin)
 plugin_cxxflags	= -Wp,-MMD,$(depfile) $(KBUILD_HOSTCXXFLAGS) -fPIC \
 		  -include $(srctree)/include/linux/compiler-version.h \
 		  -DPLUGIN_VERSION=$(call stringify,$(KERNELVERSION)) \
-		  -I $(GCC_PLUGINS_DIR)/include -I $(obj) -std=gnu++11 \
+		  -I $(GCC_PLUGINS_DIR)/include -I $(obj) \
 		  -fno-rtti -fno-exceptions -fasynchronous-unwind-tables \
 		  -ggdb -Wno-narrowing -Wno-unused-variable \
 		  -Wno-format-diag
Signature · 1 line
2.39.1
Applied
#1 lore raw
Quoted 11 lines · Sam James

The latest GCC 13 snapshot (13.0.1 20230129) gives the following:

```
cc1: error: cannot load plugin ./scripts/gcc-plugins/randomize_layout_plugin.so
 :./scripts/gcc-plugins/randomize_layout_plugin.so: undefined symbol: tree_code_type
```

This ends up being because of https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=b0241ce6e37031
upstream in GCC which changes the visibility of some types used by the kernel's plugin infrastructure like tree_code_type.

[...]

Applied to for-next/hardening, thanks!

[1/1] gcc-plugins: drop -std=gnu++11 to fix GCC 13 build

      https://git.kernel.org/kees/c/5a6b64adc18d
Signature · 1 line
Kees Cook