From 628f7ee1c41f406fb650378e79749e610ee0ee59 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Tue, 22 Dec 2020 20:26:11 +0100 Subject: [PATCH] Enable Link Time Optimization by default --- CHANGELOG.md | 1 + configure.ac | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05e7015a..94c385a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * Suppress output of all external commands. * Consider mouse support when pausing and unpausing curses interface. * Reduce CPU usage of the frequency spectrum visualizer. +* Enable Link Time Optimization by default. # ncmpcpp-0.9 (2020-12-20) * Fix various Mopidy specific bugs. diff --git a/configure.ac b/configure.ac index 8c2d85fd..ef0c52b7 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,7 @@ AC_ARG_ENABLE(clock, AS_HELP_STRING([--enable-clock], [Enable clock screen @<:@d AC_ARG_WITH(fftw, AS_HELP_STRING([--with-fftw], [Enable fftw support (required for frequency spectrum vizualization) @<:@default=auto@:>@]), [fftw=$withval], [fftw=auto]) AC_ARG_WITH(taglib, AS_HELP_STRING([--with-taglib], [Enable tag editor @<:@default=auto@:>@]), [taglib=$withval], [taglib=auto]) +AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [Enable LTO (link time optimization) @<:@default=yes@:>@]), [lto=$withval], [lto=yes]) if test "$outputs" = "yes"; then AC_DEFINE([ENABLE_OUTPUTS], [1], [enables outputs screen]) @@ -26,6 +27,25 @@ if test "$clock" = "yes"; then AC_DEFINE([ENABLE_CLOCK], [1], [enables clock screen]) fi +# -flto +if test "$lto" != "no"; then + AC_MSG_CHECKING([whether compiler supports -flto]) + old_CXXFLAGS="$CXXFLAGS" + # support specifying the number of threads + if test "$lto" != "yes"; then + flto="-flto=$lto" + else + flto="-flto" + fi + CXXFLAGS="$flto" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]])], + AC_MSG_RESULT([yes]), + AC_MSG_RESULT([no]) + flto="" + ) + CXXFLAGS="$old_CXXFLAGS $flto" +fi + # -ftree-vectorize AC_MSG_CHECKING([whether compiler supports -ftree-vectorize]) old_CXXFLAGS="$CXXFLAGS"