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])],