923a60
From 2d5ee8de927f69784d8380c24ca5505b3f6e7672 Mon Sep 17 00:00:00 2001
923a60
From: systemd team <systemd-maint@redhat.com>
923a60
Date: Tue, 14 Apr 2015 15:00:06 +0200
923a60
Subject: [PATCH] build-sys: add configure option to disableLTO/gold
923a60
923a60
---
923a60
 configure.ac | 15 ++++++++++-----
923a60
 1 file changed, 10 insertions(+), 5 deletions(-)
923a60
923a60
diff --git a/configure.ac b/configure.ac
923a60
index 081ed0f6eb..9103f9b923 100644
923a60
--- a/configure.ac
923a60
+++ b/configure.ac
923a60
@@ -208,10 +208,15 @@ AS_CASE([$CC], [*clang*],
923a60
                -Wno-gnu-variable-sized-type-not-at-end \
923a60
         ])])
923a60
 
923a60
-AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
923a60
-        [CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
923a60
-               -flto -ffat-lto-objects])],
923a60
-        [AC_MSG_RESULT([skipping -flto, optimization not enabled])])
923a60
+AC_ARG_ENABLE([lto], AS_HELP_STRING([--disable-lto], [Disable Link time optimization]))
923a60
+AS_IF([test "x$enable_lto" != "xno"], [
923a60
+AS_CASE([$CFLAGS], [*-O[[12345\ ]]*], [
923a60
+         CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [-flto -ffat-lto-objects])
923a60
+         CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS],[-Wl,-fuse-ld=gold])
923a60
+         ],
923a60
+[AC_MSG_RESULT([skipping -flto, optimization not enabled])])
923a60
+])
923a60
+
923a60
 AC_SUBST([OUR_CFLAGS], "$with_cflags $sanitizer_cflags")
923a60
 
923a60
 AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
923a60
@@ -227,7 +232,7 @@ CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
923a60
         -Wl,-z,relro \
923a60
         -Wl,-z,now \
923a60
         -pie \
923a60
-        -Wl,-fuse-ld=gold])
923a60
+        ])
923a60
 AC_SUBST([OUR_LDFLAGS], "$with_ldflags $sanitizer_ldflags")
923a60
 
923a60
 AC_CHECK_SIZEOF(pid_t)