* 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.
This commit is contained in:
Dmitry Antipov 2014-05-13 15:12:05 +04:00
parent 001da405b6
commit bd098f41af
5 changed files with 80 additions and 33 deletions

View file

@ -1,3 +1,8 @@
2014-05-13 Dmitry Antipov <dmantipov@yandex.ru>
* configure.ac (--enable-link-time-optimization): Add clang support.
* INSTALL: Mention it.
2014-05-12 Katsumi Yamaoka <yamaoka@jpl.org>
* configure.ac (EMACS_CHECK_MODULES): Fix typo in previous change.

17
INSTALL
View file

@ -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'.

View file

@ -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.

View file

@ -1,3 +1,8 @@
2014-05-13 Dmitry Antipov <dmantipov@yandex.ru>
* PROBLEMS: Mention potential problems with
--enable-link-time-optimization and clang on Fedora 20.
2014-05-04 Leo Liu <sdl.web@gmail.com>
* NEWS: Mention support for Chinese dates in calendar and diary.

View file

@ -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