chiark / gitweb /
Prep v233.4: Update LTO usage to be more convenient.
authorSven Eden <yamakuzure@gmx.net>
Fri, 21 Jul 2017 11:37:31 +0000 (13:37 +0200)
committerSven Eden <yamakuzure@gmx.net>
Wed, 26 Jul 2017 08:16:50 +0000 (10:16 +0200)
- 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

index df38297bfdf4c79841e4df290cd08084b891b214..e67cbdd607c6e2d8321fe4fb5444adb858c8f1e4 100644 (file)
@@ -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}