From bd098f41af3d0201d6b8156ecb577dbff53fa50c Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Tue, 13 May 2014 15:12:05 +0400 Subject: [PATCH] * configure.ac (--enable-link-time-optimization): Add clang support. * INSTALL: Mention it. * etc/PROBLEMS: Mention potential problems with --enable-link-time-optimization and clang on Fedora 20. --- ChangeLog | 5 ++++ INSTALL | 17 +++++++----- configure.ac | 72 ++++++++++++++++++++++++++++++++------------------- etc/ChangeLog | 5 ++++ etc/PROBLEMS | 14 ++++++++++ 5 files changed, 80 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index c66f6b726f..c4ee59eb84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-05-13 Dmitry Antipov + + * configure.ac (--enable-link-time-optimization): Add clang support. + * INSTALL: Mention it. + 2014-05-12 Katsumi Yamaoka * configure.ac (EMACS_CHECK_MODULES): Fix typo in previous change. diff --git a/INSTALL b/INSTALL index 496c6c8c37..3502631cbc 100644 --- a/INSTALL +++ b/INSTALL @@ -331,12 +331,17 @@ and is useful with GNU-compatible compilers. On a recent GNU system there should be no warnings; on older and on non-GNU systems the generated warnings may still be useful. -Use --enable-link-time-optimization to enable link-time optimizer, which -is available in GNU compiler since version 4.5.0. If your compiler is not -GNU or older than version 4.5.0, this option does nothing. If `configure' -can determine number of online CPUS on your system, final link-time -optimization and code generation is executed in parallel using one job -per each available online CPU. +Use --enable-link-time-optimization to enable link-time optimizer. If +you're using GNU compiler, this feature is supported since version 4.5.0. +If `configure' can determine number of online CPUS on your system, final +link-time optimization and code generation is executed in parallel using +one job per each available online CPU. + +This option is also supported for clang. You should have GNU binutils +with `gold' linker and plugin support, and clang with LLVMgold.so plugin. +Read http://llvm.org/docs/GoldPlugin.html for details. Also note that +this feature is still experimental, so prepare to build binutils and +clang from the corresponding source code repositories. The `--prefix=PREFIXDIR' option specifies where the installation process should put emacs and its data files. This defaults to `/usr/local'. diff --git a/configure.ac b/configure.ac index a0d6abc4b1..b2ce64adeb 100644 --- a/configure.ac +++ b/configure.ac @@ -762,32 +762,6 @@ AC_ARG_ENABLE([gcc-warnings], [gl_gcc_warnings=no] ) -AC_ARG_ENABLE(link-time-optimization, -[AS_HELP_STRING([--enable-link-time-optimization], - [build emacs with link-time optimization. - This is supported only for GCC since 4.5.0.])], -if test "${enableval}" != "no"; then - AC_MSG_CHECKING([whether link-time optimization is supported]) - ac_lto_supported=no - if test x$GCC = xyes; then - CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null` - if test x$CPUS != x; then - LTO="-flto=$CPUS" - else - LTO="-flto" - fi - old_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS $LTO" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], - [ac_lto_supported=yes], [ac_lto_supported=no]) - CFLAGS="$old_CFLAGS" - fi - AC_MSG_RESULT([$ac_lto_supported]) - if test "$ac_lto_supported" = "yes"; then - CFLAGS="$CFLAGS $LTO" - fi -fi) - # clang is unduly picky about some things. AC_CACHE_CHECK([whether the compiler is clang], [emacs_cv_clang], [AC_COMPILE_IFELSE( @@ -913,7 +887,51 @@ edit_cflags=" s/^ // " - +AC_ARG_ENABLE(link-time-optimization, +[AS_HELP_STRING([--enable-link-time-optimization], + [build emacs with link-time optimization. + This is supported for gcc since 4.5.0 and clang. + Note that clang support is experimental - see INSTALL])], +if test "${enableval}" != "no"; then + ac_lto_supported=no + if test $emacs_cv_clang = yes; then + AC_MSG_CHECKING([whether link-time optimization is supported by clang]) + GOLD_PLUGIN=`$CC -print-file-name=LLVMgold.so 2>/dev/null` + if test -x "$GOLD_PLUGIN"; then + LTO="-flto" + fi + elif test x$GCC = xyes; then + AC_MSG_CHECKING([whether link-time optimization is supported by gcc]) + CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null` + if test x$CPUS != x; then + LTO="-flto=$CPUS" + else + LTO="-flto" + fi + else + AC_MSG_ERROR([Link-time optimization is not supported with your compiler.]) + fi + if test -z "$LTO"; then + ac_lto_supported=no + else + old_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $LTO" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [ac_lto_supported=yes], [ac_lto_supported=no]) + CFLAGS="$old_CFLAGS" + fi + AC_MSG_RESULT([$ac_lto_supported]) + if test "$ac_lto_supported" = "yes"; then + CFLAGS="$CFLAGS $LTO" + if test x$emacs_cv_clang = xyes; then + AC_MSG_WARN([Please read INSTALL before using link-time optimization with clang]) + # WARNING: 'ar --plugin ...' doesn't work without + # command, so plugin name is appended to ARFLAGS. + ARFLAGS="cru --plugin $GOLD_PLUGIN" + RANLIB="$RANLIB --plugin $GOLD_PLUGIN" + fi + fi +fi) dnl Some other nice autoconf tests. dnl These are commented out, since gl_EARLY and/or Autoconf already does them. diff --git a/etc/ChangeLog b/etc/ChangeLog index 3eb1c564fa..ea0db24072 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog @@ -1,3 +1,8 @@ +2014-05-13 Dmitry Antipov + + * PROBLEMS: Mention potential problems with + --enable-link-time-optimization and clang on Fedora 20. + 2014-05-04 Leo Liu * NEWS: Mention support for Chinese dates in calendar and diary. diff --git a/etc/PROBLEMS b/etc/PROBLEMS index cf025ce4b9..6ea699384f 100644 --- a/etc/PROBLEMS +++ b/etc/PROBLEMS @@ -836,6 +836,20 @@ you want to use fcitx with Emacs, you have two choices. Toggle fcitx by another key (e.g. C-\) by modifying ~/.fcitx/config, or be accustomed to use C-@ for `set-mark-command'. +*** Link-time optimization with clang doesn't work on Fedora 20. + +As of May 2014, Fedora 20 has broken LLVMgold.so plugin support in clang +(tested with clang-3.4-6.fc20) - `clang --print-file-name=LLVMgold.so' +prints `LLVMgold.so' instead of full path to plugin shared library, and +`clang -flto' is unable to find the plugin with the following error: + +/bin/ld: error: /usr/bin/../lib/LLVMgold.so: could not load plugin library: +/usr/bin/../lib/LLVMgold.so: cannot open shared object file: No such file +or directory + +The only way to avoid this is to build your own clang from source code +repositories, as described at http://clang.llvm.org/get_started.html. + *** M-SPC seems to be ignored as input. See if your X server is set up to use this as a command -- 2.39.2