diff options
author | Tor Lillqvist <tml@iki.fi> | 2013-06-25 20:28:05 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-06-26 14:19:40 +0300 |
commit | c8238341068195827abefc0118a562b4956d5d56 (patch) | |
tree | 832a305613a54a21bd33e1455daf1844fa245053 /configure.ac | |
parent | 4d676f72bc0f1928be0e6bc2f272291f278dc95a (diff) |
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
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/configure.ac b/configure.ac index 765a973b4c75..cfe202358e21 100644 --- a/configure.ac +++ b/configure.ac @@ -850,9 +850,11 @@ AC_ARG_ENABLE(linkoo, AC_ARG_ENABLE(lto, AS_HELP_STRING([--enable-lto], [Enable link-time optimization. Suitable for product builds. - Building takes longer but libraries are optimized for speed. - (possible only with gcc-4.5 or later, - better to use gcc-4.6 and 'gold' as linker)])) + Building takes longer but libraries and executables are optimized for speed. + (For GCC, best to use GCC 4.6 or later and 'gold' linker. + Also possible for Clang. + Experimental work in progress, + don't use unless you are working on this.)])) AC_ARG_ENABLE(crashdump, AS_HELP_STRING([--enable-crashdump], @@ -2384,6 +2386,18 @@ if test "$COMPATH" = "."; then fi 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 Test the Solaris compiler version dnl =================================================================== @@ -2598,9 +2612,14 @@ if test $_os = Darwin; then stdlib="-std=c++11 -stdlib=libc++" CPP_LIBRARY="LIBCPP" fi - CC="`xcrun -find clang` $bitness -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH" - CXX="`xcrun -find clang++` $bitness $stdlib -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH" + if test "$ENABLE_LTO" = TRUE; then + 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 + AR=`xcrun -find ar` + RANLIB=`xcrun -find ranlib` ;; esac AC_MSG_RESULT([$CC and $CXX]) @@ -2735,8 +2754,14 @@ if test $_os = iOS; then AC_MSG_RESULT($sysroot) - CXX="$xcode_developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch $arch -isysroot $sysroot $versionmin" - CC="$xcode_developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch $arch -isysroot $sysroot $versionmin" + if test "$ENABLE_LTO" = TRUE; then + 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 AC_MSG_CHECKING([whether to treat the installation as read-only]) @@ -4333,18 +4358,6 @@ else fi 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 # be sure to do not mess with uneeded stuff test_randr=no |