* quoting myself from Tue, Feb 27, 2007 at 11:02:01PM CET: > * 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. [...]
While still appreciating commenting upon, I've applied both of those patches now. The second needed some trivial adjusting for Gary's quoting patch; all patches shown below. Cheers, Ralf 2007-03-06 Ralf Wildenhues <[EMAIL PROTECTED]> * libltdl/config/ltmain.m4sh (func_mode_link): Also apply the symbol filtering for w32 and the include_expsyms feature in the case of exceeded command line length. Fixes test failure on MinGW. * 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. * tests/export.at: For const data object imported from shared library, define appropriate macros to expand __declspec(dllimport) on w32. Fixes test failure on MinGW. Index: libltdl/config/ltmain.m4sh =================================================================== RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v retrieving revision 1.69 diff -u -r1.69 ltmain.m4sh --- libltdl/config/ltmain.m4sh 6 Mar 2007 00:46:56 -0000 1.69 +++ libltdl/config/ltmain.m4sh 6 Mar 2007 22:28:15 -0000 @@ -5381,6 +5381,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/export.at =================================================================== RCS file: /cvsroot/libtool/libtool/tests/export.at,v retrieving revision 1.2 diff -u -r1.2 --- tests/export.at 12 Feb 2007 20:50:36 -0000 1.2 +++ tests/export.at 6 Mar 2007 22:28:00 -0000 @@ -89,18 +89,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 @@ -134,7 +142,7 @@ ]]) 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 -DLIBA_DLL_IMPORT $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' 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 6 Mar 2007 22:28:15 -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