Kaydet (Commit) c8238341 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Experiment with LTO for OS X and iOS, too

With Clang, LTO means compiling to LLVM intermediate representation
instead of object code, and optimisation and code generation at link
time.

As expected, linking the single executable for the iOS experimental
app takes quite some time (several hours), and in fact it eventually
fails. Hopefully better luck on OS X.

Need to use xcrun to find the right ar and ranlib, too, from the
Xcode toolchain being used.

Change-Id: Iee69397c57bf1d622882ad78c188e1734f6cbd63
üst 4d676f72
...@@ -850,9 +850,11 @@ AC_ARG_ENABLE(linkoo, ...@@ -850,9 +850,11 @@ AC_ARG_ENABLE(linkoo,
AC_ARG_ENABLE(lto, AC_ARG_ENABLE(lto,
AS_HELP_STRING([--enable-lto], AS_HELP_STRING([--enable-lto],
[Enable link-time optimization. Suitable for product builds. [Enable link-time optimization. Suitable for product builds.
Building takes longer but libraries are optimized for speed. Building takes longer but libraries and executables are optimized for speed.
(possible only with gcc-4.5 or later, (For GCC, best to use GCC 4.6 or later and 'gold' linker.
better to use gcc-4.6 and 'gold' as linker)])) Also possible for Clang.
Experimental work in progress,
don't use unless you are working on this.)]))
AC_ARG_ENABLE(crashdump, AC_ARG_ENABLE(crashdump,
AS_HELP_STRING([--enable-crashdump], AS_HELP_STRING([--enable-crashdump],
...@@ -2384,6 +2386,18 @@ if test "$COMPATH" = "."; then ...@@ -2384,6 +2386,18 @@ if test "$COMPATH" = "."; then
fi fi
COMPATH=`echo $COMPATH | $SED "s@/[[Bb]][[Ii]][[Nn]]\\\$@@"` COMPATH=`echo $COMPATH | $SED "s@/[[Bb]][[Ii]][[Nn]]\\\$@@"`
# Set the ENABLE_LTO variable
# ===================================================================
AC_MSG_CHECKING([whether to use link-time optimization])
if test -n "$enable_lto" -a "$enable_lto" != "no"; then
ENABLE_LTO="TRUE"
AC_MSG_RESULT([yes])
else
ENABLE_LTO=""
AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_LTO)
dnl =================================================================== dnl ===================================================================
dnl Test the Solaris compiler version dnl Test the Solaris compiler version
dnl =================================================================== dnl ===================================================================
...@@ -2598,9 +2612,14 @@ if test $_os = Darwin; then ...@@ -2598,9 +2612,14 @@ if test $_os = Darwin; then
stdlib="-std=c++11 -stdlib=libc++" stdlib="-std=c++11 -stdlib=libc++"
CPP_LIBRARY="LIBCPP" CPP_LIBRARY="LIBCPP"
fi fi
CC="`xcrun -find clang` $bitness -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH" if test "$ENABLE_LTO" = TRUE; then
CXX="`xcrun -find clang++` $bitness $stdlib -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH" lto=-flto
fi
CC="`xcrun -find clang` $bitness $lto -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH"
CXX="`xcrun -find clang++` $bitness $lto $stdlib -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH"
XCRUN=xcrun XCRUN=xcrun
AR=`xcrun -find ar`
RANLIB=`xcrun -find ranlib`
;; ;;
esac esac
AC_MSG_RESULT([$CC and $CXX]) AC_MSG_RESULT([$CC and $CXX])
...@@ -2735,8 +2754,14 @@ if test $_os = iOS; then ...@@ -2735,8 +2754,14 @@ if test $_os = iOS; then
AC_MSG_RESULT($sysroot) AC_MSG_RESULT($sysroot)
CXX="$xcode_developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch $arch -isysroot $sysroot $versionmin" if test "$ENABLE_LTO" = TRUE; then
CC="$xcode_developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch $arch -isysroot $sysroot $versionmin" lto=-flto
fi
CC="`xcrun -find clang` -arch $arch -isysroot $sysroot $lto $versionmin"
CXX="`xcrun -find clang++` -arch $arch -isysroot $sysroot $lto $versionmin"
XCRUN=xcrun
AR=`xcrun -find ar`
RANLIB=`xcrun -find ranlib`
fi fi
AC_MSG_CHECKING([whether to treat the installation as read-only]) AC_MSG_CHECKING([whether to treat the installation as read-only])
...@@ -4333,18 +4358,6 @@ else ...@@ -4333,18 +4358,6 @@ else
fi fi
AC_SUBST(DISABLE_LINKOO) AC_SUBST(DISABLE_LINKOO)
# Set the ENABLE_LTO variable
# ===================================================================
AC_MSG_CHECKING([whether to use link-time optimization])
if test -n "$enable_lto" -a "$enable_lto" != "no"; then
ENABLE_LTO="TRUE"
AC_MSG_RESULT([yes])
else
ENABLE_LTO=""
AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_LTO)
if test "$enable_headless" = "yes"; then if test "$enable_headless" = "yes"; then
# be sure to do not mess with uneeded stuff # be sure to do not mess with uneeded stuff
test_randr=no test_randr=no
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment