Re: cross compile fails with GCC_PLUGIN_LATENT_ENTROPY

From: Kees Cook
Date: Fri Apr 04 2025 - 13:32:27 EST


On Tue, Apr 01, 2025 at 05:34:05PM -0400, Tadhg McDonald-Jensen wrote:
> Hello,
>
> When cross compiling the linux kernel with
> `CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y` it tries to compile the plugin for
> the target platform instead of for the host machine causing the
> compilation to fail.
>
> I've opened a bug on bugzilla:
> https://bugzilla.kernel.org/show_bug.cgi?id=219973
>
> Specifically I am using GNU guix and trying to compile with `ARCH=arm`
> and `CROSS_COMPILE=arm-linux-gnueabihf`, in guix the include paths are
> setup in a non typical way so if that is relevant to this error I am
> happy to provide more detail, but hopefully just the output of make
> showing `CC scripts/gcc-plugins/latent_entropy_plugin.o` instead of
> `HOSTCC` like many other files in the scripts folder is sufficient to
> reproduce and solve this issue.

If the kernel's build system can't find the right includes, that would
explain it. I'd check final depends line from scripts/gcc-plugins/Kconfig:

bool "GCC plugins"
depends on HAVE_GCC_PLUGINS
depends on CC_IS_GCC
depends on $(success,test -e $(shell,$(CC) -print-file-name=plugin)/include/plugin-version.h)

Which validates the Makefile's use of that:

GCC_PLUGINS_DIR = $(shell $(CC) -print-file-name=plugin)


--
Kees Cook