FYI: HEAD: new export.at test

2007-02-11 Thread Ralf Wildenhues
The new cmdline_wrap.test fails on most systems.  For those not so
familiar with this relatively new test: what it does is take the libtool
script, set max_cmd_len very low so that all kinds of command line
wrapping actions are triggered in link mode.  And then all those tests
in the testsuite that exercise the plain libtool script, are rerun with
the modified script.  Of course, if any of those other tests fail for
another reason, then cmdline_wrap will also fail, but of course some
failure cases are only triggered by it.

While looking into this, I noticed several distinct but related bugs:

1) The linker script and reloadable object file generation code assumed
that at least one object is present on the command line.  The
convenience tests showed that many compilers cope with only having
convenience archives listed as input to a library.  If possible, I would
like Libtool to cope with that, because it is convenient for users; if
not, then we should start to think about warning against it in
func_mode_link.  Anyway my current thinking is that we shouldn't give up
just yet.  (Also, Automake usually needs a source file for a library to
be able deduce the right --tag, but that can be worked around by passing
that manually in *_LIBTOOLFLAGS.)

2) If there are only convenience archives as library inputs, then using
-export-symbols{,-regex} would mistakenly export all symbols.  Also,
some $EGREP would on some systems try to read a nonexisting file
(causing another failure).

3) -export-symbols-regex fails to hide symbols if the command line
length was exceeded.

The convenience tests run inside cmdline_wrap expose (1), the patch
below adds a test adapted from stresstest.at that also exposes (2) and
(3) (in conjunction with cmdline_wrap).  I would like to fix all
failures at once, due to the intertwined code in ltmain.  Currently,
I'm about half-way through.  I'll post what I have in a followup mail
FYI, but won't apply it.

After this is fixed, there is still a (at least one ;-) scenario where
we don't cope with long command lines: if merely the list of passed
convenience archives exceeds the limit.  But that can be worked around
by the user, by simply subsuming some convenience archives in another
convenience archive.

Cheers,
Ralf

2007-02-11  Ralf Wildenhues  [EMAIL PROTECTED]

* tests/export.at: New test: expose -export-symbols failure
when the input consists solely of convenience archives, and
failure to not export all symbols when the command line length
is exceeded.
* Makefile.am: Adjust.

Index: Makefile.am
===
RCS file: /cvsroot/libtool/libtool/Makefile.am,v
retrieving revision 1.206
diff -u -r1.206 Makefile.am
--- Makefile.am 6 Feb 2007 19:19:45 -   1.206
+++ Makefile.am 11 Feb 2007 16:41:18 -
@@ -407,6 +407,7 @@
  tests/fail.at \
  tests/shlibpath.at \
  tests/static.at \
+ tests/export.at \
  tests/search-path.at \
  tests/destdir.at \
  tests/old-m4-iface.at \
--- /dev/null   2007-02-11 11:22:03.168311497 +0100
+++ tests/export.at 2007-02-11 17:40:24.0 +0100
@@ -0,0 +1,164 @@
+# Hand crafted tests for GNU Libtool. -*- Autotest -*-
+# Copyright 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# Test symbol exports.
+
+AT_SETUP([Export test])
+AT_KEYWORDS([libtool])
+
+AT_CHECK([$LIBTOOL --features | grep 'disable shared libraries'  (exit 77)],
+[1], [ignore])
+AT_CHECK([eval `$LIBTOOL --config | sed -n '/^archive_expsym_cmds=/,/^$/p'`
+  test -n $archive_expsym_cmds || echo false can-hide])
+can_hide=:
+test -s can-hide  can_hide=false
+
+LDFLAGS=$LDFLAGS -no-undefined
+libdir=`pwd`/inst/lib
+mkdir inst inst/lib
+
+AT_DATA(a.c,
+[[/* all kinds of data items */
+#ifdef __cplusplus
+extern C {
+#endif
+
+int v1;
+static int v2;
+int v3 = 0;
+int v4 = 1;
+extern const int v5, v6;
+extern const char *v7;
+extern const char v8[];
+extern int (*const v12) (void);
+const int v5 = 0;
+const int v6 = 1;
+const char* v7 = \01foo;
+const char v8[] = \01bar;
+int v9(void) { return v2 + 1; }
+int (*v10) (void);
+int (*v11) (void) = v9;
+int (*const v12) 

Re: FYI: HEAD: new export.at test

2007-02-11 Thread Ralf Wildenhues
* Ralf Wildenhues wrote on Sun, Feb 11, 2007 at 05:47:16PM CET:
 I would like to fix all failures at once, due to the intertwined code
 in ltmain.  Currently, I'm about half-way through.  I'll post what I
 have in a followup mail FYI, but won't apply it.

This patch makes the cmdline_wrap test pass on GNU/Linux and newer
Solaris.  Showing 'diff -b', hiding the indentation of the large
block inside `if $have_libobjs'.

Cheers,
Ralf

2007-02-11  Ralf Wildenhues  [EMAIL PROTECTED]

Fix -export-symbols and -export-symbols-regex for links that
exceed the command line length and use convenience archives.

* libltdl/config/ltmain.m4sh (func_mode_link) have_libobjs:
New variable, to avoid being sensitive to $libobjs containing a
single space.
(func_mode_link): Avoid grepping a nonexistent file if using
reloadable objects.  Do not create a linker script nor a linker
input file if no objects are passed.  Apply export_symbols_regex
in case the command line length is exceeded.

Index: libltdl/config/ltmain.m4sh
===
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.62
diff -u -b -r1.62 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  11 Feb 2007 16:22:42 -  1.62
+++ libltdl/config/ltmain.m4sh  11 Feb 2007 18:15:35 -
@@ -5088,6 +5088,11 @@
# Use standard objects if they are pic
test -z $pic_flag  libobjs=`$ECHO X$libobjs | $SP2NL | $Xsed -e 
$lo2o | $NL2SP`
 
+   case $libobjs in
+   *[[!\ ]]*) have_libobjs=: ;;
+   *) have_libobjs=false ;;
+   esac
+
delfiles=
if test -n $export_symbols  test -n $include_expsyms; then
  $opt_dry_run || cp $export_symbols $output_objdir/$libname.uexp
@@ -5140,7 +5145,7 @@
  fi
done
IFS=$save_ifs
-   if test -n $export_symbols_regex; then
+   if test -n $export_symbols_regex  test X$skipped_export != 
X:; then
  func_show_eval '$EGREP -e $export_symbols_regex 
$export_symbols  ${export_symbols}T'
  func_show_eval '$MV ${export_symbols}T $export_symbols'
fi
@@ -5251,7 +5256,7 @@
  last_robj=
  k=1
 
- if test X$skipped_export != X:  test $with_gnu_ld = yes; then
+ if $have_libobjs  test X$skipped_export != X:  test 
$with_gnu_ld = yes; then
output=${output_objdir}/${output_la}.lnkscript
func_echo creating GNU ld script: $output
$ECHO 'INPUT ('  $output
@@ -5261,7 +5266,7 @@
done
$ECHO ')'  $output
delfiles=$delfiles $output
- elif test X$skipped_export != X:  test X$file_list_spec != X; 
then
+ elif $have_libobjs  test X$skipped_export != X:  test 
X$file_list_spec != X; then
output=${output_objdir}/${output_la}.lnk
func_echo creating linker input file list: $output
:  $output
@@ -5272,6 +5277,7 @@
delfiles=$delfiles $output
output=\$file_list_spec$output\
  else
+   if $have_libobjs; then
func_echo creating reloadable object files...
output=$output_objdir/$output_la-${k}.$objext
# Loop over the list of objects to be linked.
@@ -5306,15 +5312,6 @@
test -z $concat_cmds || concat_cmds=$concat_cmds~
eval concat_cmds=\\${concat_cmds}$reload_cmds $objlist $last_robj\
 
-   if ${skipped_export-false}; then
- func_echo generating symbol list for \`$libname.la'
- export_symbols=$output_objdir/$libname.exp
- $opt_dry_run || $RM $export_symbols
- libobjs=$output
- # Append the command to create the export file.
- eval concat_cmds=\\$concat_cmds~$export_symbols_cmds\
-   fi
-
# Set up a command to remove the reloadable object files
# after they are used.
i=0
@@ -5323,7 +5320,21 @@
  i=`expr $i + 1`
  delfiles=$delfiles $output_objdir/$output_la-${i}.$objext
done
+   else
+ output=
+   fi
 
+   if ${skipped_export-false}; then
+ func_echo generating symbol list for \`$libname.la'
+ export_symbols=$output_objdir/$libname.exp
+ $opt_dry_run || $RM $export_symbols
+ libobjs=$output
+ # Append the command to create the export file.
+ test -z $concat_cmds || concat_cmds=$concat_cmds~
+ eval concat_cmds=\\$concat_cmds$export_symbols_cmds\
+   fi
+
+   $have_libobjs 
func_echo creating a temporary reloadable object file: $output
 
# Loop through the commands generated above and execute them.
@@ -5348,6 +5359,11 @@
  }
done
IFS=$save_ifs
+
+   if test -n 

Re: FYI: HEAD: new export.at test

2007-02-11 Thread Bob Friesenhahn

On Sun, 11 Feb 2007, Ralf Wildenhues wrote:


* Ralf Wildenhues wrote on Sun, Feb 11, 2007 at 05:47:16PM CET:

I would like to fix all failures at once, due to the intertwined code
in ltmain.  Currently, I'm about half-way through.  I'll post what I
have in a followup mail FYI, but won't apply it.


This patch makes the cmdline_wrap test pass on GNU/Linux and newer
Solaris.  Showing 'diff -b', hiding the indentation of the large
block inside `if $have_libobjs'.


Provided that this patch does not increase the test error count prior 
to test #49, I am happy with it. :-)


Bob



Cheers,
Ralf

2007-02-11  Ralf Wildenhues  [EMAIL PROTECTED]

Fix -export-symbols and -export-symbols-regex for links that
exceed the command line length and use convenience archives.

* libltdl/config/ltmain.m4sh (func_mode_link) have_libobjs:
New variable, to avoid being sensitive to $libobjs containing a
single space.
(func_mode_link): Avoid grepping a nonexistent file if using
reloadable objects.  Do not create a linker script nor a linker
input file if no objects are passed.  Apply export_symbols_regex
in case the command line length is exceeded.

Index: libltdl/config/ltmain.m4sh
===
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.62
diff -u -b -r1.62 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  11 Feb 2007 16:22:42 -  1.62
+++ libltdl/config/ltmain.m4sh  11 Feb 2007 18:15:35 -
@@ -5088,6 +5088,11 @@
# Use standard objects if they are pic
test -z $pic_flag  libobjs=`$ECHO X$libobjs | $SP2NL | $Xsed -e 
$lo2o | $NL2SP`

+   case $libobjs in
+   *[[!\ ]]*) have_libobjs=: ;;
+   *) have_libobjs=false ;;
+   esac
+
delfiles=
if test -n $export_symbols  test -n $include_expsyms; then
  $opt_dry_run || cp $export_symbols $output_objdir/$libname.uexp
@@ -5140,7 +5145,7 @@
  fi
done
IFS=$save_ifs
-   if test -n $export_symbols_regex; then
+   if test -n $export_symbols_regex  test X$skipped_export != 
X:; then
  func_show_eval '$EGREP -e $export_symbols_regex $export_symbols  
${export_symbols}T'
  func_show_eval '$MV ${export_symbols}T $export_symbols'
fi
@@ -5251,7 +5256,7 @@
  last_robj=
  k=1

- if test X$skipped_export != X:  test $with_gnu_ld = yes; then
+ if $have_libobjs  test X$skipped_export != X:  test 
$with_gnu_ld = yes; then
output=${output_objdir}/${output_la}.lnkscript
func_echo creating GNU ld script: $output
$ECHO 'INPUT ('  $output
@@ -5261,7 +5266,7 @@
done
$ECHO ')'  $output
delfiles=$delfiles $output
- elif test X$skipped_export != X:  test X$file_list_spec != X; 
then
+ elif $have_libobjs  test X$skipped_export != X:  test 
X$file_list_spec != X; then
output=${output_objdir}/${output_la}.lnk
func_echo creating linker input file list: $output
:  $output
@@ -5272,6 +5277,7 @@
delfiles=$delfiles $output
output=\$file_list_spec$output\
  else
+   if $have_libobjs; then
func_echo creating reloadable object files...
output=$output_objdir/$output_la-${k}.$objext
# Loop over the list of objects to be linked.
@@ -5306,15 +5312,6 @@
test -z $concat_cmds || concat_cmds=$concat_cmds~
eval concat_cmds=\\${concat_cmds}$reload_cmds $objlist $last_robj\

-   if ${skipped_export-false}; then
- func_echo generating symbol list for \`$libname.la'
- export_symbols=$output_objdir/$libname.exp
- $opt_dry_run || $RM $export_symbols
- libobjs=$output
- # Append the command to create the export file.
- eval concat_cmds=\\$concat_cmds~$export_symbols_cmds\
-   fi
-
# Set up a command to remove the reloadable object files
# after they are used.
i=0
@@ -5323,7 +5320,21 @@
  i=`expr $i + 1`
  delfiles=$delfiles $output_objdir/$output_la-${i}.$objext
done
+   else
+ output=
+   fi

+   if ${skipped_export-false}; then
+ func_echo generating symbol list for \`$libname.la'
+ export_symbols=$output_objdir/$libname.exp
+ $opt_dry_run || $RM $export_symbols
+ libobjs=$output
+ # Append the command to create the export file.
+ test -z $concat_cmds || concat_cmds=$concat_cmds~
+ eval concat_cmds=\\$concat_cmds$export_symbols_cmds\
+   fi
+
+   $have_libobjs 
func_echo creating a temporary reloadable object file: $output

# Loop through the commands generated