From 6d2ea709f9893cdec87f05e76ee71faab5b3a556 Mon Sep 17 00:00:00 2001
From: "Peter W. Draper" <p.w.draper@durham.ac.uk>
Date: Wed, 6 Feb 2019 11:28:27 +0000
Subject: [PATCH] Update the IPO support for GCC and CLANG.

Note that you may need to define "AR", "LD" and "RANLIB", if the names do not
match the default ones (clang/llvm are often trailed by version numbers).
---
 configure.ac | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 4b883488cc..4f899e1a5e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -104,9 +104,17 @@ if test "$enable_ipo" = "yes"; then
    elif test "$ax_cv_c_compiler_vendor" = "gnu"; then
       CFLAGS="$CFLAGS -flto"
       LDFLAGS="$LDFLAGS -flto"
+      AX_COMPARE_VERSION($ax_cv_c_compiler_version, [ge], [5.0.0],
+                          [
+      : ${AR="gcc-ar"}
+      : ${RANLIB="gcc-ranlib"}
+                          ], [:] )
       AC_MSG_RESULT([added GCC interprocedural optimization support])
    elif test "$ax_cv_c_compiler_vendor" = "clang"; then
-      CFLAGS="$CFLAGS -emit-llvm"
+      CFLAGS="$CFLAGS -flto"
+      : ${AR="llvm-ar"}
+      : ${LD="llvm-ld"}
+      : ${RANLIB="llvm-ranlib"}
       AC_MSG_RESULT([added LLVM interprocedural optimization support])
    else
       AC_MSG_WARN([Compiler does not support interprocedural optimization])
-- 
GitLab