From d7475d4073b5ff63207b010ec1249dfb64374cf6 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sat, 1 Mar 2025 11:24:19 -0600 Subject: [PATCH] configure.ac: enable -ffat-lto-objects with -flto when available Without -ffat-lto-objects libguile.a ends up with no symbols, visible via "nm t libguile.a". cf. https://lintian.debian.org/tags/no-code-sections.html * configure.ac: enable -ffat-lto-objects with -flto when available. --- NEWS | 3 +++ configure.ac | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/NEWS b/NEWS index 7429127db..053f46f0a 100644 --- a/NEWS +++ b/NEWS @@ -90,6 +90,9 @@ every line in a file. This used to trigger a warning, unduly. ** SRFI-19: 'date->string' converter ~V is now correctly interpreted () +** When -flto is enabled configure now adds -ffat-lto-objects if it exists + Otherwise libguile.a can end up with no code. + https://lintian.debian.org/tags/no-code-sections.html Changes in 3.0.10 (since 3.0.9) diff --git a/configure.ac b/configure.ac index af9176b46..f3a05ec70 100644 --- a/configure.ac +++ b/configure.ac @@ -98,6 +98,24 @@ else AC_MSG_RESULT([no]) fi +# https://lintian.debian.org/tags/no-code-sections.html +if test "$LTO_CFLAGS"; then + if ! test "$LTO_CFLAGS" = -flto; then # currently expected below + AC_MSG_ERROR([LTO_CFLAGS wasn't just -flto]) + fi + AC_MSG_CHECKING([whether the compiler supports -ffat-lto-objects]) + old_CFLAGS="$CFLAGS" + LTO_CFLAGS="-flto -ffat-lto-objects" + CFLAGS="$CFLAGS $LTO_CFLAGS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([int foo;], [])],, [LTO_CFLAGS=-flto]) + CFLAGS="$old_CFLAGS" + if test -n "$LTO_CFLAGS"; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi +fi + AC_ARG_ENABLE(lto, [AS_HELP_STRING([--enable-lto] [enable link-time optimization for libguile])],