* NEWS: Update. * libltdl/config/ltmain.m4sh (func_mode_link): Allow through flags matching -O*, -flto*, -fwhopr, -fuse-linker-plugin. * libltdl/m4/libtool.m4 (_LT_CMD_GLOBAL_SYMBOLS): Drop symbols starting with __gnu_lto. (_LT_LINKER_SHLIBS) [linux] <archive_cmds, archive_expsyms_cmds>: Add $pic_flag for GCC. (_LT_LANG_CXX_CONFIG) [linux] <archive_cmds, archive_expsyms_cmds>: Likewise. <output_verbose_link_cmd>: Only list lines starting with a space and containing 'collect'. (_LT_SYS_HIDDEN_LIBDEPS): Ignore files matching *.lto.o. Suggested by Török Edwin and Simon Richter.
Signed-off-by: Ralf Wildenhues <ralf.wildenh...@gmx.de> --- This patch still needs output_verbose_link_cmd to be fixed wrt. http://thread.gmane.org/gmane.comp.gcc.devel/112719 and probably tested to work with icpc (which likes to pretend it's GCC). The propagation of -O* for non-GCC compilers has not been tested yet. Cheers, Ralf ChangeLog | 15 +++++++++++++++ NEWS | 1 + libltdl/config/ltmain.m4sh | 4 +++- libltdl/m4/libtool.m4 | 10 ++++++---- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e274ea..b324240 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 2010-04-04 Ralf Wildenhues <ralf.wildenh...@gmx.de> + Support GCC LTO on GNU/Linux. + * NEWS: Update. + * libltdl/config/ltmain.m4sh (func_mode_link): Allow through + flags matching -O*, -flto*, -fwhopr, -fuse-linker-plugin. + * libltdl/m4/libtool.m4 (_LT_CMD_GLOBAL_SYMBOLS): Drop symbols + starting with __gnu_lto. + (_LT_LINKER_SHLIBS) [linux] <archive_cmds, archive_expsyms_cmds>: + Add $pic_flag for GCC. + (_LT_LANG_CXX_CONFIG) [linux] <archive_cmds, archive_expsyms_cmds>: + Likewise. + <output_verbose_link_cmd>: Only list lines starting with a space + and containing 'collect'. + (_LT_SYS_HIDDEN_LIBDEPS): Ignore files matching *.lto.o. + Suggested by Török Edwin and Simon Richter. + Use linker_flags not compiler_flags with $LD. * libltdl/m4/libtool.m4 (_LT_LINKER_SHLIBS) [linux] <archive_cmds, archive_expsym_cmds>: With xlf and bgxlf diff --git a/NEWS b/NEWS index ac5a40c..f220f28 100644 --- a/NEWS +++ b/NEWS @@ -38,6 +38,7 @@ New in 2.2.8 2010-??-??: git version 2.2.7a, Libtool team: - With binutils 2.19.50+, shared libraries can be built on AIX. - Initial support for the Cuda Compiler Driver on GNU/Linux. - Support for Haiku (i586-pc-haiku). + - Support for GCC link-time optimization (LTO) flags. * Bug fixes: diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index 9e6646f..b4a23f6 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -4494,8 +4494,10 @@ func_mode_link () # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection + # -O*, -flto*, -fwhopr, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ - -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*) + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*| \ + -O*|-flto*|-fwhopr|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4 index 5e0bba7..a946493 100644 --- a/libltdl/m4/libtool.m4 +++ b/libltdl/m4/libtool.m4 @@ -3434,6 +3434,7 @@ for ac_symprfx in "" "_"; do else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no @@ -4451,7 +4452,7 @@ _LT_EOF if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then - tmp_addflag= + tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler @@ -5521,8 +5522,8 @@ if test "$_lt_caught_CXX_error" != yes; then # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' @@ -5554,7 +5555,7 @@ if test "$_lt_caught_CXX_error" != yes; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .*collect"' else GXX=no @@ -6547,6 +6548,7 @@ if AC_TRY_EVAL(ac_compile); then fi ;; + *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. -- 1.7.0.rc1.161.g90487