Skip to contentSkip to conversation

mips gcc plugin issues

DISCUSSION Jeff Johnson 3 participants 5 messages Jun 18, 2024 – Jun 20, 2024

lore
Share & tools
lore
#0 lore raw

I'm trying to do an allmodconfig build for ARCH=mips using:
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-mips-linux.tar.gz

This build dies quickly with:
CC scripts/mod/empty.o
cc1: error: cannot load plugin ./scripts/gcc-plugins/randomize_layout_plugin.so: ./scripts/gcc-plugins/randomize_layout_plugin.so: undefined symbol: _ZNK6frange6acceptERK14vrange_visitor
cc1: error: cannot load plugin ./scripts/gcc-plugins/latent_entropy_plugin.so: ./scripts/gcc-plugins/latent_entropy_plugin.so: undefined symbol: _ZNK6frange6acceptERK14vrange_visitor
CC scripts/mod/devicetable-offsets.s
make[2]: *** [scripts/Makefile.build:244: scripts/mod/empty.o] Error 1
make[2]: *** Waiting for unfinished jobs....
cc1: error: cannot load plugin ./scripts/gcc-plugins/randomize_layout_plugin.so: ./scripts/gcc-plugins/randomize_layout_plugin.so: undefined symbol: _ZNK6frange6acceptERK14vrange_visitor
cc1: error: cannot load plugin ./scripts/gcc-plugins/latent_entropy_plugin.so: ./scripts/gcc-plugins/latent_entropy_plugin.so: undefined symbol: _ZNK6frange6acceptERK14vrange_visitor
HDRINST usr/include/linux/usb/tmc.h
make[2]: *** [scripts/Makefile.build:117: scripts/mod/devicetable-offsets.s] Error 1

I see the following in my .config:
CONFIG_HAVE_GCC_PLUGINS=y
CONFIG_GCC_PLUGINS=y
CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
CONFIG_GCC_PLUGIN_RANDSTRUCT=y

So I'll turn those off, but just want to flag that this issue exists. Seems either the plugins should work or the allmodconfig should turn them off.

/jeff

#1 lore raw
Quoted 15 lines · Jeff Johnson

I'm trying to do an allmodconfig build for ARCH=mips using:
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-mips-linux.tar.gz

This build dies quickly with:
CC scripts/mod/empty.o
cc1: error: cannot load plugin ./scripts/gcc-plugins/randomize_layout_plugin.so: ./scripts/gcc-plugins/randomize_layout_plugin.so: undefined symbol: _ZNK6frange6acceptERK14vrange_visitor
cc1: error: cannot load plugin ./scripts/gcc-plugins/latent_entropy_plugin.so: ./scripts/gcc-plugins/latent_entropy_plugin.so: undefined symbol: _ZNK6frange6acceptERK14vrange_visitor
CC scripts/mod/devicetable-offsets.s
make[2]: *** [scripts/Makefile.build:244: scripts/mod/empty.o] Error 1
make[2]: *** Waiting for unfinished jobs....
cc1: error: cannot load plugin ./scripts/gcc-plugins/randomize_layout_plugin.so: ./scripts/gcc-plugins/randomize_layout_plugin.so: undefined symbol: _ZNK6frange6acceptERK14vrange_visitor
cc1: error: cannot load plugin ./scripts/gcc-plugins/latent_entropy_plugin.so: ./scripts/gcc-plugins/latent_entropy_plugin.so: undefined symbol: _ZNK6frange6acceptERK14vrange_visitor
HDRINST usr/include/linux/usb/tmc.h
make[2]: *** [scripts/Makefile.build:117: scripts/mod/devicetable-offsets.s] Error 1

Quoted 8 lines

I see the following in my .config:
CONFIG_HAVE_GCC_PLUGINS=y
CONFIG_GCC_PLUGINS=y
CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
CONFIG_GCC_PLUGIN_RANDSTRUCT=y

So I'll turn those off, but just want to flag that this issue exists. Seems either the plugins should work or the allmodconfig should turn them off.

Well, the plugins work with all the other compiler versions all the various CI systems use. :) For example, I don't see this with distro cross compilers:

$ mipsel-linux-gnu-gcc --version
mipsel-linux-gnu-gcc (Ubuntu 12.3.0-1ubuntu1) 12.3.0

I suspect this is a problem with the kernel.org crosstool builds? I'm CCing Arnd, who might know more about this.

-Kees

Signature · 1 line
Kees Cook
#2 lore raw
Quoted 14 lines · Kees Cook
Quoted 8 lines · Jeff Johnson

I see the following in my .config:
CONFIG_HAVE_GCC_PLUGINS=y
CONFIG_GCC_PLUGINS=y
CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
CONFIG_GCC_PLUGIN_RANDSTRUCT=y

So I'll turn those off, but just want to flag that this issue exists. Seems either the plugins should work or the allmodconfig should turn them off.

Well, the plugins work with all the other compiler versions all the various CI systems use. :) For example, I don't see this with distro cross compilers:

Quoted 5 lines
$ mipsel-linux-gnu-gcc --version
mipsel-linux-gnu-gcc (Ubuntu 12.3.0-1ubuntu1) 12.3.0

I suspect this is a problem with the kernel.org crosstool builds? I'm CCing Arnd, who might know more about this.

Yes, this is a known problem, and I don't think there is a good solution for it, compiler plugins on cross-compilers are inherently fragile.

The problem here is that a gcc plugin links against the compiler, not against code produced by it. I'm linking the crosstool compilers statically against libraries as much as possible in order to make them more portable between distros, but the downside of that is that plugins will only work in the environment that I was using to build these toolchains.

My build environment is an older Debian (in order to be portable to old glibc versions), but with the system compiler updated to gcc-13 (since x86 libgcc cannot be cross-compiled with an older compiler).

The long-term solution of course is to replace all the gcc plugins with some other way of getting the same features, but that will still take some time.

Arnd

#3 lore raw
Quoted 32 lines · Arnd Bergmann
Quoted 14 lines · Kees Cook
Quoted 8 lines · Jeff Johnson

I see the following in my .config:
CONFIG_HAVE_GCC_PLUGINS=y
CONFIG_GCC_PLUGINS=y
CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
CONFIG_GCC_PLUGIN_RANDSTRUCT=y

So I'll turn those off, but just want to flag that this issue exists. Seems either the plugins should work or the allmodconfig should turn them off.

Well, the plugins work with all the other compiler versions all the various CI systems use. :) For example, I don't see this with distro cross compilers:

Quoted 5 lines
$ mipsel-linux-gnu-gcc --version
mipsel-linux-gnu-gcc (Ubuntu 12.3.0-1ubuntu1) 12.3.0

I suspect this is a problem with the kernel.org crosstool builds? I'm CCing Arnd, who might know more about this.

Yes, this is a known problem, and I don't think there is a good solution for it, compiler plugins on cross-compilers are inherently fragile.

The problem here is that a gcc plugin links against the compiler, not against code produced by it. I'm linking the crosstool compilers statically against libraries as much as possible in order to make them more portable between distros, but the downside of that is that plugins will only work in the environment that I was using to build these toolchains.

Quoted 4 lines

My build environment is an older Debian (in order to be portable to old glibc versions), but with the system compiler updated to gcc-13 (since x86 libgcc cannot be cross-compiled with an older compiler).

Can the crosstools remove the plugin support? That seems like the best solution. Kconfig test for plugin availability with:

	depends on $(success,test -e $(shell,$(CC) -print-file-name=plugin)/include/plugin-version.h)
Quoted 3 lines

The long-term solution of course is to replace all the gcc plugins with some other way of getting the same features, but that will still take some time.

Agreed. There's not much motion on the GCC side of this, though.

Signature · 1 line
Kees Cook
#4 lore raw
Quoted 15 lines · Kees Cook
Quoted 9 lines · Arnd Bergmann

On Wed, Jun 19, 2024, at 22:50, Kees Cook wrote:

The problem here is that a gcc plugin links against the compiler, not against code produced by it. I'm linking the crosstool compilers statically against libraries as much as possible in order to make them more portable between distros, but the downside of that is that plugins will only work in the environment that I was using to build these toolchains.

Quoted 4 lines

My build environment is an older Debian (in order to be portable to old glibc versions), but with the system compiler updated to gcc-13 (since x86 libgcc cannot be cross-compiled with an older compiler).

Quoted 5 lines

Can the crosstools remove the plugin support? That seems like the best solution. Kconfig test for plugin availability with:

	depends on $(success,test -e $(shell,$(CC) 

-print-file-name=plugin)/include/plugin-version.h)

Good idea, yes. I still have to upload gcc-14.1 and gcc-13.3 binaries anyway, so I'll try turning off plugin support when I build it.

Arnd