[m-rev.] for review: Make link-time optimisation with gcc work.
Peter Wang
novalazy at gmail.com
Tue Jan 28 10:59:26 AEDT 2020
configure.ac:
Add -flto to LINK_SHARED_OBJ and LINK_SHARED_OBJ_SH commands
when LTO is enabled with gcc.
Search for and use LTO-aware gcc-ar, gcc-ranlib and gcc-nm
programs in place of the normal tools.
diff --git a/configure.ac b/configure.ac
index 3e7e10c09..6dbee8860 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5348,7 +5348,19 @@ if test "$mercury_cv_lto" = "yes"; then
CFLAGS_FOR_LTO="-GL"
LDFLAGS_FOR_LTO="-LTCG"
;;
- gcc*|clang*)
+ gcc*)
+ CFLAGS_FOR_LTO="-flto"
+ LDFLAGS_FOR_LTO="-flto"
+ LINK_SHARED_OBJ="$LINK_SHARED_OBJ -flto"
+ LINK_SHARED_OBJ_SH="$LINK_SHARED_OBJ_SH -flto"
+ AC_CHECK_TOOL([GCC_AR], [gcc-ar], [])
+ AC_CHECK_TOOL([GCC_RANLIB], [gcc-ranlib], [])
+ AC_CHECK_TOOL([GCC_NM], [gcc-nm], [])
+ AR=${GCC_AR:-$AR}
+ RANLIB=${GCC_RANLIB:-$RANLIB}
+ NM=${GCC_NM:-$NM}
+ ;;
+ clang*)
CFLAGS_FOR_LTO="-flto"
LDFLAGS_FOR_LTO="-flto"
;;
--
2.25.0
More information about the reviews
mailing list