libtool-patches
[Top][All Lists]
Advanced

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

FYI: HEAD: new export.at test


From: Ralf Wildenhues
Subject: FYI: HEAD: new export.at test
Date: Sun, 11 Feb 2007 17:47:16 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

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

        * 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 -0000       1.206
+++ Makefile.am 11 Feb 2007 16:41:18 -0000
@@ -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.000000000 +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) (void) = v9;
+
+typedef struct { int arr[1000]; } large;
+large v13;
+large v14 = { { 0 } };
+large v15 = { { 1 } };
+
+int w1 (void) { return 0; }
+
+#ifdef __cplusplus
+}
+#endif
+]])
+
+AT_DATA(asyms,
+[[v1
+v3
+v4
+v5
+v6
+v7
+v8
+v9
+v10
+v11
+v12
+v13
+v14
+v15
+]])
+
+AT_DATA(main.c,
+[[
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern int v1;
+extern int v3, v4;
+extern const int v5, v6;
+extern const char* v7;
+extern const char v8[];
+extern int v9(void);
+extern int (*v10) (void);
+extern int (*v11) (void);
+extern int (*const v12) (void);
+#ifdef __cplusplus
+}
+#endif
+
+typedef struct { int arr[1000]; } large;
+extern large v13, v14, v15;
+
+int main (void)
+{
+  char s = v7[0] + v8[0];
+  return s + v1 + v3 + v4 + v5 + v6 + v9() + v11() + v12()
+          + v13.arr[0] + v14.arr[0] + v15.arr[0]
+           - 8;
+}
+]])
+
+AT_DATA([broken.c],
+[[
+/* these symbols should not be exported */
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern int w1 (void);
+#ifdef __cplusplus
+}
+#endif
+int main (void)
+{
+  return w1 ();
+}
+]])
+
+AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c 
a.c],[0],[ignore],[ignore])
+AT_CHECK([$CC $CPPFLAGS $CFLAGS -c main.c],[0],[ignore],[ignore])
+AT_CHECK([$CC $CPPFLAGS $CFLAGS -c broken.c],[0],[ignore],[ignore])
+
+for exportsyms in '' '-export-symbols-regex "v.*"' '-export-symbols asyms'
+do
+  # case 1: shared library built from object.
+  LT_AT_CHECK([eval '$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la a.lo 
\
+              -rpath $libdir' $exportsyms], [], [ignore], [ignore])
+  AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main main.$OBJEXT 
liba.la],
+          [], [ignore], [ignore])
+  LT_AT_EXEC_CHECK([./main])
+  if test -n "$exportsyms" && $can_hide; then
+    AT_CHECK([if $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o broken 
broken.$OBJEXT liba.la
+             then (exit 1); else :; fi], [], [ignore], [ignore])
+  fi
+
+  # case 2: shared library built from convenience archive.
+  AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o libconv.la a.lo],
+          [], [ignore], [ignore])
+  LT_AT_CHECK([eval '$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la 
libconv.la \
+              -rpath $libdir' $exportsyms], [], [ignore], [ignore])
+  AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main main.$OBJEXT 
liba.la],
+          [], [ignore], [ignore])
+  LT_AT_EXEC_CHECK([./main])
+  if test -n "$exportsyms" && $can_hide; then
+    AT_CHECK([if $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o broken 
broken.$OBJEXT liba.la
+             then (exit 1); else :; fi], [], [ignore], [ignore])
+  fi
+done
+
+AT_CLEANUP




reply via email to

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