libtool-patches
[Top][All Lists]
Advanced

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

Re: export.at failure on MinGW


From: Ralf Wildenhues
Subject: Re: export.at failure on MinGW
Date: Tue, 27 Feb 2007 23:02:01 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

* Charles Wilson wrote on Tue, Feb 27, 2007 at 05:42:50AM CET:
> Ralf Wildenhues wrote:
> >I suggest this patch to fix the export test on MinGW.  It did not fail
> >on Cygwin due to auto-import, but on MinGW it did for the data objects.
> 
> That is odd, because mingw supports auto-import too.  (However, it might 
> be "off" by default, since libraries created that way wouldn't be usable 
> by msvc, which is one of the goals of mingw, at least for 
> non-name-mangled languages.)  So, yeah, being a little more careful 
> about declspec() niceties for mingw is probably a good thing.

If I can see correctly, then it's the *const* data objects that still
seem to need an auto-import.

> >WDYT?  I guess stresstest.at needs a similar fix, but there the same
> >code is currently used to link against a shared and a static version of
> >the library, so that would need to be fixed as well.
> 
> Hmm.

See below for the stresstest patch that works for me mostly.  After
fixing the dllimport issue, low max_cmd_len + stresstest exposed two
more failures: I forgot to duplicate the part about include_expsyms and
the export filter for DATA exports.

The other failure is kind of cute: it's also a low max_cmd_len +
stresstest failure.  There, we try to link an object file with an
absolute name.  The command length evasion then puts this absolute
name into the GNU ld linker script.  This bypasses MSYS path
translation, so ld gets a path like /home/ralf/.. instead of C:\...
Funny, I had to laugh about this one.  I don't think we need to fix
this in ltmain at the moment, it's really rather an extreme case.
(Maybe we should fix it in stresstest.at.)

> >The only thing that's then still worrying me is that on Cygwin, the
> >mdemo and mdemo_static programs sometimes throw segmentation faults
> >on my system.  Not all the time though.
> 
> Well, it's failing all the time for me, but I'm not sure it's a 
> segfault. What does "Hangup" mean, when reported by the shell after 
> executing the app:

Good question, I don't know.  I suppose there is memory corruption
earlier, and due to it anything weird can happen later, so the exit
status is not really reliable.

Cheers, and thanks,
Ralf

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

        * tests/stresstest.at: For const data object imported from
        shared library, define appropriate macros to expand
        __declspec(dllimport) on w32.  Use two different main objects
        and pick the right one for the link flags we are about to test.
        Fixes test failure on MinGW.

Index: libltdl/config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.68
diff -u -r1.68 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  23 Feb 2007 21:52:50 -0000      1.68
+++ libltdl/config/ltmain.m4sh  27 Feb 2007 22:01:52 -0000
@@ -5380,6 +5380,28 @@
            fi
          fi
 
+          if ${skipped_export-false}; then
+           if test -n "$export_symbols" && test -n "$include_expsyms"; then
+             tmp_export_symbols="$export_symbols"
+             test -n "$orig_export_symbols" && 
tmp_export_symbols="$orig_export_symbols"
+             $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL 
>> "$tmp_export_symbols"'
+           fi
+
+           if test -n "$orig_export_symbols"; then
+             # The given exports_symbols file has to be filtered, so filter it.
+             func_echo "filter symbol list for \`$libname.la' to tag DATA 
exports"
+             # FIXME: $output_objdir/$libname.filter potentially contains lots 
of
+             # 's' commands which not all seds can handle. GNU sed should be 
fine
+             # though. Also, the filter scales superlinearly with the number of
+             # global variables. join(1) would be nice here, but unfortunately
+             # isn't a blessed tool.
+             $opt_dry_run || $SED -e '/[[ ,]]DATA/!d;s,\(.*\)\([[ 
\,]].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+             delfiles="$delfiles $export_symbols 
$output_objdir/$libname.filter"
+             export_symbols=$output_objdir/$libname.def
+             $opt_dry_run || $SED -f $output_objdir/$libname.filter < 
$orig_export_symbols > $export_symbols
+           fi
+         fi
+
          libobjs=$output
          # Restore the value of output.
          output=$save_output
Index: tests/stresstest.at
===================================================================
RCS file: /cvsroot/libtool/libtool/tests/stresstest.at,v
retrieving revision 1.13
diff -u -r1.13 stresstest.at
--- tests/stresstest.at 6 Feb 2007 19:02:27 -0000       1.13
+++ tests/stresstest.at 27 Feb 2007 22:01:52 -0000
@@ -84,18 +84,26 @@
 
 AT_DATA(main.c,
 [[
+#if defined(LIBA_DLL_IMPORT)
+#  if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__)
+#    define LIBA_SCOPE extern __declspec(dllimport)
+#  endif
+#endif
+#if !defined(LIBA_SCOPE)
+#  define LIBA_SCOPE extern
+#endif
 #ifdef __cplusplus
 extern "C" {
 #endif
 extern int v1;
 extern int v3, v4;
-extern const int v5, v6;
+LIBA_SCOPE 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);
+LIBA_SCOPE int (*const v12) (void);
 #ifdef __cplusplus
 }
 #endif
@@ -113,18 +121,27 @@
 ]])
 
 AT_DATA(dlself.c,
-[[#ifdef __cplusplus
+[[
+#if defined(LIBA_DLL_IMPORT)
+#  if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__)
+#    define LIBA_SCOPE extern __declspec(dllimport)
+#  endif
+#endif
+#if !defined(LIBA_SCOPE)
+#  define LIBA_SCOPE extern
+#endif
+#ifdef __cplusplus
 extern "C" {
 #endif
 extern int v1;
 extern int v3, v4;
-extern const int v5, v6;
+LIBA_SCOPE 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);
+LIBA_SCOPE int (*const v12) (void);
 
 typedef struct { int arr[1000]; } large;
 extern large v13, v14, v15;
@@ -195,10 +212,18 @@
 ]])
 
 
-AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c -o 
sub/a.lo],[0],[ignore],[ignore])
-AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c b.c -o 
sub/b.lo],[0],[ignore],[ignore])
-AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c 
main.c],[0],[ignore],[ignore])
-AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c dlself.c -o 
sub3/dlself.lo],[0],[ignore],[ignore])
+AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c -o sub/a.lo],
+        [0],[ignore],[ignore])
+AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c b.c -o sub/b.lo],
+        [0],[ignore],[ignore])
+AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS -DLIBA_DLL_IMPORT $CFLAGS -c 
main.c],
+        [0],[ignore],[ignore])
+AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c main.c -o 
main-static.lo],
+        [0],[ignore],[ignore])
+AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS -DLIBA_DLL_IMPORT $CFLAGS -c 
dlself.c -o sub3/dlself.lo],
+        [0],[ignore],[ignore])
+AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c dlself.c -o 
sub3/dlself-static.lo],
+        [0],[ignore],[ignore])
 
 case $allow_undefined_flag in
   unsupported) undef_opts=-no-undefined ;;
@@ -221,12 +246,17 @@
                 [0],[ignore],[ignore])
        for st in '' '-static'
        do
-         LT_AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS $st -o 
"$rel"main "$rel"main.lo "$rel"sub2/liba.la],
+          case $st,$l3 in
+          ,-rpath*) mst= ;;
+          *) mst=-static ;;
+         esac
+
+         LT_AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS $st -o 
"$rel"main "$rel"main$mst.lo "$rel"sub2/liba.la],
                   [0],[ignore],[ignore])
          LT_AT_EXEC_CHECK([./main],[0])
          for l10 in '' '-export-symbols dlselfsyms'
          do
-           LT_AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS $st -o 
"$rel"sub3/dlself "$rel"sub3/dlself.lo "$rel"sub2/liba.la sub/b.lo -dlopen self 
$l10],
+           LT_AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS $st -o 
"$rel"sub3/dlself "$rel"sub3/dlself$mst.lo "$rel"sub2/liba.la sub/b.lo -dlopen 
self $l10],
                     [0],[ignore],[ignore])
            LT_AT_EXEC_CHECK([./sub3/dlself],[0])
          done




reply via email to

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