From 7e17c59e6b33219e1d478a74852a64d4c726d76b Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Fri, 21 Jul 2017 13:37:31 +0200 Subject: [PATCH 1/1] Prep v233.4: Update LTO usage to be more convenient. - Add -fuse-linker-plugin to work around odd compiler and binutils installs. Should fix most "plugin needed to handle lto object" issues. - Read back whether LTO really has been enabled or not, so we can display a status line at the end of configure. - Only enforce gold linker if LTO has been enabled. These checks can still be disabled with the --disable-lto option, which will make configure to skip all checks regarding LTO. --- configure.ac | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index df38297bf..e67cbdd60 100644 --- a/configure.ac +++ b/configure.ac @@ -247,14 +247,20 @@ AS_CASE([$CC], [*clang*], ])]) # ------------------------------------------------------------------------------ +have_lto=no AC_ARG_ENABLE([lto], [AS_HELP_STRING([--disable-lto], [disable -flto])], [], [enable_lto=yes]) AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*], - [AS_IF([test "x$enable_lto" = "xyes"], - [CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [-flto])], + [AS_IF([test "x$enable_lto" = "xyes"], [have_lto=yes], [AC_MSG_RESULT([disabling -flto as requested])])], [AC_MSG_RESULT([skipping -flto, optimization not enabled])]) +AS_IF([test "x$have_lto" = "xyes"], + [CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], + [-flto -fuse-linker-plugin])]) + +AS_CASE([$with_cflags], [*-flto*], [], [have_lto=no]) + # ------------------------------------------------------------------------------ AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*], [CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\ @@ -279,8 +285,9 @@ CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\ -Wl,--no-undefined \ -Wl,-z,relro \ -Wl,-z,now \ - -pie \ - -Wl,-fuse-ld=gold]) + -pie]) +AS_IF([test "x$have_lto" = "xyes"], + [CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [-Wl,-fuse-ld=gold])]) # ------------------------------------------------------------------------------ AC_SUBST([OUR_CPPFLAGS], "$with_cppflags $sanitizer_cppflags") @@ -865,6 +872,7 @@ AC_MSG_RESULT([ test coverage: . . . . . . . . . . ${have_coverage} Split /usr: . . . . . . . . . . . ${enable_split_usr} utmp/wtmp support: . . . . . . . . ${have_utmp} + Link time optimization: . . . . . ${have_lto} extra debugging: . . . . . . . . . ${enable_debug} cgroup controller: . . . . . . . . ${with_cgroupctrl} -- 2.30.2