Subject: bug#73582: guile-3.0 build system adding unnecessary pkg-config & guile-config compile flags

From: "Wouter Bijlsma" <[email-masked]>
Date: Mon, 30 Sep 2024 21:43:27 +0200

Hello,

I believe I may have found a bug in the guile 3.0 build system.

When configuring and building on systems that have libgmp installed, the guile build system will add '-I$LIBGMP_PREFIX' to the set of compiler flags reported by 'pkg-config --cflags guile-3.0' (and hence also 'guile-config compile'). At least on my configuration (Arch Linux), the value of $LIBGMP_PREFIX is (predictably) '/usr', which results in '-I/usr' being added to the GUILE_CFLAGS in the 'configure' script, which will subsequently be substituted for @GUILE_CFLAGS@ to generate the meta/guile-3.0.pc pkg-config script that will be installed along with guile. 

The net result is that any project that uses pkg-config to find guile (e.g. from CMake) will implicitly add -I/usr to its own compiler flags, which is not just unnecessary but also causes IDE's that use the compiler flags to find include directories to index, to recursively have to index everything in /usr (which is a lot).

I cannot imagine a prefix path to be intentionally added as an include path, and simply removing it does not break anything (not building guile itself, nor building projects that depend on it), so I assume this is a bug?

The code that adds $LIBGMP_PREFIX to the $GUILE_CFLAGS is in the 'configure.ac' script, which defines the GMP checking code, to end up in the configure script. As mentioned, if I simply remove it from the configure script, guile compiles fine, and projects that use the generated pkg-config also build without issue.

All this is using the latest guile 3.0.10 tarball by the way.

Regards,
-Wouter