fix(guile-gnutls): use static guile pkg-config libs for configure link checks

This commit is contained in:
vxtls 2026-03-05 10:16:26 -05:00
parent 451fdc63ca
commit 9205c2b1e4
2 changed files with 59 additions and 7 deletions

View file

@ -6,15 +6,16 @@ src_prepare() {
} }
src_configure() { src_configure() {
local host_triplet pkg_config_path guile_cflags guile_libs gnutls_libs local host_triplet pkg_config_path guile_cflags guile_static_libs gnutls_static_libs gnutls_link_flags
host_triplet="$(gcc -dumpmachine)" host_triplet="$(gcc -dumpmachine)"
pkg_config_path="${LIBDIR}/pkgconfig:${PREFIX}/lib/pkgconfig:${PREFIX}/share/pkgconfig" pkg_config_path="${LIBDIR}/pkgconfig:${PREFIX}/lib/pkgconfig:${PREFIX}/share/pkgconfig"
guile_cflags="$(PKG_CONFIG_LIBDIR="${pkg_config_path}" PKG_CONFIG_PATH="${pkg_config_path}" \ guile_cflags="$(PKG_CONFIG_LIBDIR="${pkg_config_path}" PKG_CONFIG_PATH="${pkg_config_path}" \
/usr/bin/pkg-config --cflags guile-3.0)" /usr/bin/pkg-config --cflags guile-3.0)"
guile_libs="$(PKG_CONFIG_LIBDIR="${pkg_config_path}" PKG_CONFIG_PATH="${pkg_config_path}" \ guile_static_libs="$(PKG_CONFIG_LIBDIR="${pkg_config_path}" PKG_CONFIG_PATH="${pkg_config_path}" \
/usr/bin/pkg-config --libs guile-3.0)" /usr/bin/pkg-config --static --libs guile-3.0)"
gnutls_libs="$(PKG_CONFIG_LIBDIR="${pkg_config_path}" PKG_CONFIG_PATH="${pkg_config_path}" \ gnutls_static_libs="$(PKG_CONFIG_LIBDIR="${pkg_config_path}" PKG_CONFIG_PATH="${pkg_config_path}" \
/usr/bin/pkg-config --libs gnutls)" /usr/bin/pkg-config --static --libs gnutls)"
gnutls_link_flags="-Wl,-Bstatic ${gnutls_static_libs} -Wl,-Bdynamic"
PATH="${PREFIX}/bin:/usr/bin:/bin" \ PATH="${PREFIX}/bin:/usr/bin:/bin" \
PKG_CONFIG="/usr/bin/pkg-config" \ PKG_CONFIG="/usr/bin/pkg-config" \
@ -22,8 +23,8 @@ src_configure() {
PKG_CONFIG_PATH="${pkg_config_path}" \ PKG_CONFIG_PATH="${pkg_config_path}" \
LD_LIBRARY_PATH="${LIBDIR}:${PREFIX}/lib:${LD_LIBRARY_PATH}" \ LD_LIBRARY_PATH="${LIBDIR}:${PREFIX}/lib:${LD_LIBRARY_PATH}" \
GUILE_CFLAGS="${guile_cflags}" \ GUILE_CFLAGS="${guile_cflags}" \
GUILE_LIBS="${guile_libs}" \ GUILE_LIBS="${guile_static_libs}" \
GNUTLS_LIBS="${gnutls_libs}" \ GNUTLS_LIBS="${gnutls_link_flags}" \
./configure \ ./configure \
--prefix="${PREFIX}" \ --prefix="${PREFIX}" \
--libdir="${LIBDIR}" \ --libdir="${LIBDIR}" \
@ -43,3 +44,26 @@ src_compile() {
src_install() { src_install() {
default_src_install default_src_install
} }
src_postprocess() {
local module_path
default_src_postprocess
module_path="$(find "${DESTDIR}${LIBDIR}/guile" -type f -name 'guile-gnutls-v-2.so' | head -n1)"
if [ -z "${module_path}" ] || [ ! -f "${module_path}" ]; then
echo "guile-gnutls: extension module not found after install." >&2
false
fi
if command -v readelf >/dev/null 2>&1; then
if readelf -d "${module_path}" | grep -q 'NEEDED.*libguile'; then
echo "guile-gnutls: extension must not link libguile directly." >&2
false
fi
if readelf -d "${module_path}" | grep -q 'NEEDED.*libgnutls'; then
echo "guile-gnutls: extension must link gnutls stack statically." >&2
false
fi
fi
}

View file

@ -0,0 +1,28 @@
SPDX-License-Identifier: GPL-3.0-or-later
Keep the Guile extension model while avoiding a second libguile copy inside
the extension module.
When Guile itself is built without shared libguile, linking the extension
against libguile can embed another runtime copy and lead to crashes. Rely on
symbols from the hosting Guile process instead.
--- guile-gnutls-v5.0.1/guile/src/Makefile.am
+++ guile-gnutls-v5.0.1/guile/src/Makefile.am
@@ -40,14 +40,13 @@
# Use '-module' to build a "dlopenable module", in Libtool terms.
# Use '-undefined' to placate Libtool on Windows; see
# <https://lists.gnutls.org/pipermail/gnutls-devel/2014-December/007294.html>.
-guile_gnutls_v_2_la_LDFLAGS = -module -no-undefined
+guile_gnutls_v_2_la_LDFLAGS = -module
guile_gnutls_v_2_la_SOURCES = core.c errors.c utils.c
guile_gnutls_v_2_la_CFLAGS = \
$(AM_CFLAGS) $(GNULIB_CFLAGS) $(GUILE_CFLAGS) $(GNUTLS_CFLAGS)
guile_gnutls_v_2_la_LIBADD = \
- $(GNUTLS_LIBS) \
- $(GUILE_LDFLAGS)
+ $(GNUTLS_LIBS)
AM_CPPFLAGS = \
-I$(top_srcdir)/lib/includes \