This patch enables compilation with -flto.

The performance benefits of LTO (GCC 4.9 & 6.1) are about 1% for glxgears.
Performance changes in OpenGL games haven't been measured yet, my feeling
is that they are negligible.
diff --git a/configure.ac b/configure.ac
index fc0b1db..e84a1ad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -362,6 +362,8 @@ if test "x$GXX" = xyes; then
     CXXFLAGS="$CXXFLAGS -fno-builtin-memcmp"
 fi
 
+AX_CHECK_COMPILE_FLAG([-flto], AM_CONDITIONAL(COMPILER_UNDERSTANDS_LTO, true), AM_CONDITIONAL(COMPILER_UNDERSTANDS_LTO, false))
+
 AC_SUBST([MSVC2013_COMPAT_CFLAGS])
 AC_SUBST([MSVC2013_COMPAT_CXXFLAGS])
 
diff --git a/src/mapi/Makefile.am b/src/mapi/Makefile.am
index 68a28a2..4b7d266 100644
--- a/src/mapi/Makefile.am
+++ b/src/mapi/Makefile.am
@@ -51,6 +51,11 @@ AM_CPPFLAGS =							\
 
 include Makefile.sources
 
+if COMPILER_UNDERSTANDS_LTO
+CFLAGS += -fno-lto
+CXXFLAGS += -fno-lto
+endif
+
 MKDIR_GEN = $(AM_V_at)$(MKDIR_P) $(@D)
 PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS)
 
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to