libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: HEAD: new tag variable compiler_needs_object


From: Ralf Wildenhues
Subject: FYI: HEAD: new tag variable compiler_needs_object
Date: Fri, 23 Feb 2007 22:10:40 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

This patch adds a new tag variable compiler_needs_object: when the
compiler driver won't invoke the linker with
  -Wl,--whole-archive,libfoo,... or -Wl,-c,filelist

only but actually needs an object listed, because it otherwise thinks
there is nothing to do.  The Sun C/C++ compilers on GNU/Linux are an
example of the first; the HP-UX C compiler does not notice a file list
given to its linker with -Wl,-c,filelist.  We don't implement the latter
quite yet...

This means that you need no longer add a dummy object to your library
created from a set of convenience libraries (other than for Automake to
get the right tag; or supply it with AM_LIBTOOLFLAGS).

Cheers,
Ralf

2007-02-23  Ralf Wildenhues  <address@hidden>

        * libltdl/m4/libtool.m4 (_LT_LINKER_SHLIBS)
        <compiler_needs_object>: New tag variable.  Default to `no'.
        (_LT_LINKER_SHLIBS) [ linux ]: Set it to yes for Sun C 5.9.
        (_LT_LANG_CXX_CONFIG): Also default it to `no'.
        [ linux ]: Set it to `yes' for Sun C++ 5.9.
        * libltdl/config/ltmain.m4sh (func_mode_link): If we link
        no objects but only convenience archives into a library,
        force expansion if `compiler_needs_object' is yes.
        For creating a linker input filelist due to long cmdline,
        extract the first object if `compiler_needs_object' is yes.
        * doc/libtool.texi (libtool script contents): Document it.
        Fixes test failures of Sun compilers on GNU/Linux.
        Report by Terry D. Dontje.

Index: doc/libtool.texi
===================================================================
RCS file: /cvsroot/libtool/libtool/doc/libtool.texi,v
retrieving revision 1.219
diff -u -r1.219 libtool.texi
--- doc/libtool.texi    11 Feb 2007 11:11:05 -0000      1.219
+++ doc/libtool.texi    23 Feb 2007 21:09:49 -0000
@@ -5259,6 +5259,13 @@
 simultaneously.  Set to @samp{yes} or @samp{no}.
 @end defvar
 
address@hidden compiler_needs_object
+Whether the compiler has to see an object listed on the command line in
+order to successfully invoke the linker.  If @samp{no}, then a set of
+convenience archives or a set of object file names can be passed via
+linker-specific options or linker scripts.
address@hidden defvar
+
 @defvar dlopen_support
 Whether @code{dlopen} is supported on the platform.
 Set to @samp{yes} or @samp{no}.
Index: libltdl/config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.66
diff -u -r1.66 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  23 Feb 2007 20:43:50 -0000      1.66
+++ libltdl/config/ltmain.m4sh  23 Feb 2007 21:09:52 -0000
@@ -5182,6 +5182,13 @@
        deplibs="$tmp_deplibs"
 
        if test -n "$convenience"; then
+         if test -n "$whole_archive_flag_spec" &&
+           test "$compiler_needs_object" = yes &&
+           test -z "$libobjs"; then
+           # extract the archives, so we have objects to list.
+           # TODO: could optimize this to just extract one archive.
+           whole_archive_flag_spec=
+         fi
          if test -n "$whole_archive_flag_spec"; then
            save_libobjs=$libobjs
            eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
@@ -5270,12 +5277,19 @@
            output=${output_objdir}/${output_la}.lnk
            func_echo "creating linker input file list: $output"
            : > $output
-           for obj in $save_libobjs
+           set x $save_libobjs
+           shift
+           firstobj=
+           if test "$compiler_needs_object" = yes; then
+             firstobj="$1 "
+             shift
+           fi
+           for obj
            do
              $ECHO "$obj" >> $output
            done
            delfiles="$delfiles $output"
-           output=\"$file_list_spec$output\"
+           output=$firstobj\"$file_list_spec$output\"
          else
            func_echo "creating reloadable object files..."
            output=$output_objdir/$output_la-${k}.$objext
Index: libltdl/m4/libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/m4/libtool.m4,v
retrieving revision 1.96
diff -u -r1.96 libtool.m4
--- libltdl/m4/libtool.m4       17 Feb 2007 15:15:23 -0000      1.96
+++ libltdl/m4/libtool.m4       23 Feb 2007 21:09:54 -0000
@@ -4003,6 +4003,7 @@
   _LT_TAGVAR(always_export_symbols, $1)=no
   _LT_TAGVAR(archive_cmds, $1)=
   _LT_TAGVAR(archive_expsym_cmds, $1)=
+  _LT_TAGVAR(compiler_needs_object, $1)=no
   _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
   _LT_TAGVAR(export_dynamic_flag_spec, $1)=
   _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | 
$global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
@@ -4195,6 +4196,7 @@
        case `$CC -V 2>&1 | sed 5q` in
        *Sun\ C*)                       # Sun C 5.9
          _LT_TAGVAR(whole_archive_flag_spec, 
$1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do 
test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO 
\"$new_convenience\"` ${wl}--no-whole-archive'
+         _LT_TAGVAR(compiler_needs_object, $1)=yes
          tmp_sharedflag='-G' ;;
        *Sun\ F*)                       # Sun Fortran 8.3
          tmp_sharedflag='-G' ;;
@@ -4994,6 +4996,8 @@
     [Compiler flag to allow reflexive dlopens])
 _LT_TAGDECL([], [whole_archive_flag_spec], [1],
     [Compiler flag to generate shared objects directly from archives])
+_LT_TAGDECL([], [compiler_needs_object], [1],
+    [Whether the compiler copes with passing no objects directly])
 _LT_TAGDECL([], [old_archive_from_new_cmds], [2],
     [Create an old-style archive from a shared archive])
 _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
@@ -5183,6 +5187,7 @@
 _LT_TAGVAR(allow_undefined_flag, $1)=
 _LT_TAGVAR(always_export_symbols, $1)=no
 _LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(compiler_needs_object, $1)=no
 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
 _LT_TAGVAR(hardcode_direct, $1)=no
 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
@@ -5851,6 +5856,7 @@
              _LT_TAGVAR(archive_expsym_cmds, $1)='$CC 
-G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs 
$postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
              _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
              _LT_TAGVAR(whole_archive_flag_spec, 
$1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do 
test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO 
\"$new_convenience\"` ${wl}--no-whole-archive'
+             _LT_TAGVAR(compiler_needs_object, $1)=yes
 
              # Not sure whether something based on
              # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]