[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Some fixes for cygwin
From: |
Charles Wilson |
Subject: |
Some fixes for cygwin |
Date: |
Fri, 03 May 2002 02:34:06 -0400 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011019 Netscape6/6.2 |
Having wrestled with libtool for a few days, I've found a number of
additional fixes needed for operation on cygwin. These patches,
however, won't get you "perfect" operation. You also need a modified
automake, because the Makefile's generated by automake within the
testsuite don't clean up after themselves very well. When building a
statically-linked executable in a directory where a previous build of
dynamically-linked exe left a wrapper script behing, well, problems
ensue. This happens often in the testsuite.
See this message and the thread following it:
http://mail.gnu.org/pipermail/automake-patches/2002-May/000785.html
Anyway, that's orthogonal to this:
2002-05-03 Charles Wilson <address@hidden>
* libtool.m4: use $NM to create the symbol list on cygwin, not
$ltdll_cmds as on mingw. For all tags, (and host=cygwin) set
allow_undefined_flag="" so that the --auto-import magic
works properly. For all tags (and host=cygiwn) set
always_export_symbols=no -- it is unnecessary thanks to
binutils' auto-export magic.
* libltdl/ltdl.c: Don't force cygwin to use the LoadLibrary
wrapper; use cygwin's builtin implementatino of dl*.
* cdemo/Makefile.am: the downside of unsetting
'allow_undefined_flag' -- we must include -no-undefined
in the _la_LDFLAGS variable.
* depdemo/l1/Makefile.am: ditto
* depdemo/l2/Makefile.am: ditto
* depdemo/l3/Makefile.am: ditto
* depdemo/l4/Makefile.am: ditto
* mdemo/Makefile.am: ditto
* tagdemo/Makefile.am: ditto
* demo/Makefile.am: ditto. But also, we must make special
provision to clean up the hell0 wrapper script.
* pdemo/Makefile.am: ditto -no-undefined. ditto hell0.
And use 'hell_static' instead of 'hell.static'
* demo/configure.ac: use -all-static, not -static.
* depdemo/configure.ac: ditto
* mdemo/configure.ac: ditto
* pdemo/configure.ac: ditto
* tests/build-relink2.test: look for installed libl3.la
in $prefix/lib/ as well as $prefix/lib/extra/.
Most of it should be pretty self-explanatory, but a few specific notes:
demo/Makefile.am and pdemo/Makefile.am: hell0 wrapper script. Even
with the new-and-improved automake, that only takes care of wrappers and
executables that are part of bin_PROGRAMS. since hell0 is in
EXTRA_PROGRAMS, it is "cleaned up" by a special ad hoc "CLEANFILES"
variable. However, only one of its two incarnations gets cleaned up
this way -- and then, only when building statically. When building
dynamically, hell0.exe doesn't exist at all -- but that's what
CLEANFILES ends up having thanks to some transforms in the Makefile.
So, explicitly add 'hell0' to CLEANFILES. It won't get transformed
there, so at worst you just try to remove the same file twice. Also,
since the dynamically-linked exe is actually in .libs/hell0.exe, the 'rm
-rf .libs' in the 'clean-libtool' rule will clean that up for you.
The configure.ac changes: libtool 'eats' the "-static" argument; you
have to feed "-all-static" to libtool, in order to convince it
to put "$link_static_flag" in the gcc command line. Otherwise,
hell_static.exe is actually linked to the DLL. I suspect this is
probably true on other platforms, too...
build-relink2.test: This was one problem with the test -- libl3.la
doesn't get installed into _inst/lib/extra, and it isn't supposed to.
So look for it in the right place, _inst/lib/. However, that didn't fix
the OTHER problems that cygwin has with that test...
I've attached the patch, as well as my running notes when I was doing
the tests and investigating the failures (I figure those should go here
just to get them "on the record").
--Chuck
? .build
? .inst
? .sinst
? autom4te.cache
? COPYING
? CYGWIN-PATCHES
? INSTALL
? install-sh
? missing
? mkinstalldirs
? cdemo/autom4te.cache
? demo/autom4te.cache
? depdemo/autom4te.cache
? libltdl/autom4te.cache
? libltdl/config-h.in
? mdemo/autom4te.cache
? pdemo/autom4te.cache
? tagdemo/autom4te.cache
Index: libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/libtool.m4,v
retrieving revision 1.254
diff -u -u -r1.254 libtool.m4
--- libtool.m4 2 May 2002 14:22:51 -0000 1.254
+++ libtool.m4 3 May 2002 04:34:08 -0000
@@ -2575,8 +2575,8 @@
# _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
# as there is no search path for DLLs.
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+ _LT_AC_TAGVAR(always_export_symbols, $1)=no
if $LD --help 2>&1 | egrep 'auto-import' > /dev/null; then
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects
$libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname
${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
@@ -4371,6 +4371,9 @@
_LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience
| awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) &&
([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
fi
;;
+ cygwin*)
+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience |
$global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
mingw* | pw32*)
_LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
;;
@@ -4479,8 +4482,8 @@
# _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
# as there is no search path for DLLs.
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+ _LT_AC_TAGVAR(always_export_symbols, $1)=no
if $LD --help 2>&1 | egrep 'auto-import' > /dev/null; then
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs
$compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000
${wl}--out-implib,$lib'
@@ -4780,7 +4783,7 @@
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=
# Tell ltmain to make .lib files, not .a files.
libext=lib
# FIXME: Setting linknames here is a bad hack.
Index: cdemo/Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/cdemo/Makefile.am,v
retrieving revision 1.6
diff -u -u -r1.6 Makefile.am
--- cdemo/Makefile.am 30 Mar 1999 19:22:23 -0000 1.6
+++ cdemo/Makefile.am 3 May 2002 04:34:08 -0000
@@ -8,6 +8,7 @@
libfoo_la_SOURCES = foo.c
libfoo_la_LIBADD = $(LIBM)
+libfoo_la_LDFLAGS = -no-undefined
noinst_HEADERS = foo.h
Index: demo/Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/demo/Makefile.am,v
retrieving revision 1.27
diff -u -u -r1.27 Makefile.am
--- demo/Makefile.am 3 Mar 2002 03:19:55 -0000 1.27
+++ demo/Makefile.am 3 May 2002 04:34:08 -0000
@@ -8,7 +8,7 @@
lib_LTLIBRARIES = libhello.la
libhello_la_SOURCES = hello.c foo.c
libhello_la_LIBADD = $(LIBM)
-libhello_la_LDFLAGS = -version-info 3:12:1
+libhello_la_LDFLAGS = -no-undefined -version-info 3:12:1
include_HEADERS = foo.h
@@ -125,16 +125,20 @@
EXTRA_LTLIBRARIES = libhell1.la libhell2.la
libhell1_la_SOURCES = hell1.c
libhell1_la_LIBADD = -L. -lhell0
-libhell1_la_LDFLAGS = -rpath $(libdir)
+libhell1_la_LDFLAGS = -no-undefined -rpath $(libdir)
libhell1_la_DEPENDENCIES = libhell0.a
libhell2_la_SOURCES = hell2.c
libhell2_la_LIBADD = -L. -lhell0
-libhell2_la_LDFLAGS = -rpath $(libdir)
+libhell2_la_LDFLAGS = -no-undefined -rpath $(libdir)
libhell2_la_DEPENDENCIES = libhell0.a
EXTRA_PROGRAMS = hell0
hell0_SOURCES = main.c
hell0_LDADD = libhell1.la libhell2.la $(LIBM)
-CLEANFILES += $(EXTRA_LIBRARIES) $(EXTRA_LTLIBRARIES) $(EXTRA_PROGRAMS)
+# 'hell0' in EXTRA_PROGRAMS gets translated to 'hell0.exe'; but we
+# must explicitly list the wrapper script 'hell0'. (bin_PROGRAMS
+# are handled seamlessly by automake rules; the extra step is only
+# necessary for EXTRA_PROGRAMS)
+CLEANFILES += $(EXTRA_LIBRARIES) $(EXTRA_LTLIBRARIES) $(EXTRA_PROGRAMS) hell0
deplibs-check: hell0$(EXEEXT)
Index: demo/configure.ac
===================================================================
RCS file: /cvsroot/libtool/libtool/demo/configure.ac,v
retrieving revision 1.4
diff -u -u -r1.4 configure.ac
--- demo/configure.ac 3 Mar 2002 03:19:55 -0000 1.4
+++ demo/configure.ac 3 May 2002 04:34:08 -0000
@@ -49,7 +49,7 @@
AC_SUBST([LIBTOOL_DEPS])
if ./libtool --features | grep '^enable static libraries$' > /dev/null 2>&1;
then
- STATIC=-static
+ STATIC=-all-static
else
STATIC=
fi
Index: depdemo/configure.ac
===================================================================
RCS file: /cvsroot/libtool/libtool/depdemo/configure.ac,v
retrieving revision 1.4
diff -u -u -r1.4 configure.ac
--- depdemo/configure.ac 3 Mar 2002 03:19:55 -0000 1.4
+++ depdemo/configure.ac 3 May 2002 04:34:08 -0000
@@ -30,7 +30,7 @@
## depdemo specific configuration. ##
## ------------------------------- ##
if ${CONFIG_SHELL} ./libtool --features | grep "enable static" >/dev/null; then
- STATIC=-static
+ STATIC=-all-static
else
STATIC=
fi
Index: depdemo/l1/Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/depdemo/l1/Makefile.am,v
retrieving revision 1.4
diff -u -u -r1.4 Makefile.am
--- depdemo/l1/Makefile.am 2 Apr 1999 09:37:03 -0000 1.4
+++ depdemo/l1/Makefile.am 3 May 2002 04:34:08 -0000
@@ -6,3 +6,4 @@
lib_LTLIBRARIES = libl1.la
libl1_la_SOURCES = l1.c l1.h
+libl1_la_LDFLAGS = -no-undefined
Index: depdemo/l2/Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/depdemo/l2/Makefile.am,v
retrieving revision 1.4
diff -u -u -r1.4 Makefile.am
--- depdemo/l2/Makefile.am 2 Apr 1999 09:37:07 -0000 1.4
+++ depdemo/l2/Makefile.am 3 May 2002 04:34:08 -0000
@@ -6,4 +6,5 @@
lib_LTLIBRARIES = libl2.la
libl2_la_SOURCES = l2.c l2.h
+libl2_la_LDFLAGS = -no-undefined
libl2_la_LIBADD = $(top_builddir)/l1/libl1.la
Index: depdemo/l3/Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/depdemo/l3/Makefile.am,v
retrieving revision 1.6
diff -u -u -r1.6 Makefile.am
--- depdemo/l3/Makefile.am 3 Mar 2002 03:19:55 -0000 1.6
+++ depdemo/l3/Makefile.am 3 May 2002 04:34:08 -0000
@@ -8,4 +8,5 @@
lib_LTLIBRARIES = libl3.la
libl3_la_SOURCES = l3.c l3.h
+libl3_la_LDFLAGS = -no-undefined
libl3_la_LIBADD = $(top_builddir)/l1/libl1.la $(top_builddir)/l2/libl2.la
Index: depdemo/l4/Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/depdemo/l4/Makefile.am,v
retrieving revision 1.5
diff -u -u -r1.5 Makefile.am
--- depdemo/l4/Makefile.am 2 Apr 1999 09:37:11 -0000 1.5
+++ depdemo/l4/Makefile.am 3 May 2002 04:34:08 -0000
@@ -6,4 +6,5 @@
lib_LTLIBRARIES = libl4.la
libl4_la_SOURCES = l4.c l4.h
+libl4_la_LDFLAGS = -no-undefined
libl4_la_LIBADD = $(top_builddir)/l3/libl3.la $(LIBM)
Index: libltdl/ltdl.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/ltdl.c,v
retrieving revision 1.163
diff -u -u -r1.163 ltdl.c
--- libltdl/ltdl.c 3 Mar 2002 03:19:55 -0000 1.163
+++ libltdl/ltdl.c 3 May 2002 04:34:09 -0000
@@ -911,11 +911,7 @@
/* --- DLOPEN() INTERFACE LOADER --- */
-/* Older Cygwin dlopen implementations print a spurious error message to
- stderr if the call to LoadLibrary() fails for any reason. We can
- mitigate this by not using the Cygwin implementation, and falling
- back to our own LoadLibrary() wrapper. */
-#if HAVE_LIBDL && !defined(__CYGWIN__)
+#if HAVE_LIBDL
/* dynamic linking with dlopen/dlsym */
@@ -1734,7 +1730,7 @@
handles = 0;
user_search_path = 0; /* empty search path */
-#if HAVE_LIBDL && !defined(__CYGWIN__)
+#if HAVE_LIBDL
errors += lt_dlloader_add (lt_dlloader_next (0), &sys_dl, "dlopen");
#endif
#if HAVE_SHL_LOAD
Index: mdemo/Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/mdemo/Makefile.am,v
retrieving revision 1.45
diff -u -u -r1.45 Makefile.am
--- mdemo/Makefile.am 3 Mar 2002 03:19:55 -0000 1.45
+++ mdemo/Makefile.am 3 May 2002 04:34:09 -0000
@@ -10,7 +10,7 @@
foo1_la_SOURCES = foo1.c
foo1_la_LIBADD = $(LIBM) libsub.la
-foo1_la_LDFLAGS = -module -avoid-version
+foo1_la_LDFLAGS = -no-undefined -module -avoid-version
libfoo2_la_SOURCES = foo2.c
libfoo2_la_LIBADD = $(LIBM) libsub.la
Index: mdemo/configure.ac
===================================================================
RCS file: /cvsroot/libtool/libtool/mdemo/configure.ac,v
retrieving revision 1.3
diff -u -u -r1.3 configure.ac
--- mdemo/configure.ac 6 Oct 2001 15:35:17 -0000 1.3
+++ mdemo/configure.ac 3 May 2002 04:34:09 -0000
@@ -52,7 +52,7 @@
AC_SUBST(LIBTOOL_DEPS)
if ${CONFIG_SHELL} ./libtool --features | grep "enable static" >/dev/null; then
- STATIC=-static
+ STATIC=-all-static
else
STATIC=
fi
Index: pdemo/Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/pdemo/Makefile.am,v
retrieving revision 1.4
diff -u -u -r1.4 Makefile.am
--- pdemo/Makefile.am 5 Sep 2001 19:52:17 -0000 1.4
+++ pdemo/Makefile.am 3 May 2002 04:34:09 -0000
@@ -8,7 +8,7 @@
lib_LTLIBRARIES = libhello.la
libhello_la_SOURCES = longer_file_name_hello.c longer_file_name_foo.c
longer_file_name_foo2.c
libhello_la_LIBADD = $(LIBM)
-libhello_la_LDFLAGS = -version-info 3:12:1
+libhello_la_LDFLAGS = -no-undefined -version-info 3:12:1
include_HEADERS = foo.h
@@ -18,7 +18,7 @@
BUILD_helldl =
endif
-bin_PROGRAMS = hell hell.static $(BUILD_helldl)
+bin_PROGRAMS = hell hell_static $(BUILD_helldl)
# Build hell from longer_file_name_main.c and libhello.la
hell_SOURCES = longer_file_name_main.c
@@ -125,16 +125,20 @@
EXTRA_LTLIBRARIES = libhell1.la libhell2.la
libhell1_la_SOURCES = longer_file_name_hell1.c
libhell1_la_LIBADD = -L. -lhell0
-libhell1_la_LDFLAGS = -rpath $(libdir)
+libhell1_la_LDFLAGS = -no-undefined -rpath $(libdir)
libhell1_la_DEPENDENCIES = libhell0.a
libhell2_la_SOURCES = longer_file_name_hell2.c
libhell2_la_LIBADD = -L. -lhell0
-libhell2_la_LDFLAGS = -rpath $(libdir)
+libhell2_la_LDFLAGS = -no-undefined -rpath $(libdir)
libhell2_la_DEPENDENCIES = libhell0.a
EXTRA_PROGRAMS = hell0
hell0_SOURCES = longer_file_name_main.c
hell0_LDADD = libhell1.la libhell2.la $(LIBM)
-CLEANFILES += $(EXTRA_LIBRARIES) $(EXTRA_LTLIBRARIES) $(EXTRA_PROGRAMS)
+# 'hell0' in EXTRA_PROGRAMS gets translated to 'hell0.exe'; but we
+# must explicitly list the wrapper script 'hell0'. (bin_PROGRAMS
+# are handled seamlessly by automake rules; the extra step is only
+# necessary for EXTRA_PROGRAMS)
+CLEANFILES += $(EXTRA_LIBRARIES) $(EXTRA_LTLIBRARIES) $(EXTRA_PROGRAMS) hell0
deplibs-check: hell0
Index: pdemo/configure.ac
===================================================================
RCS file: /cvsroot/libtool/libtool/pdemo/configure.ac,v
retrieving revision 1.3
diff -u -u -r1.3 configure.ac
--- pdemo/configure.ac 6 Oct 2001 15:35:17 -0000 1.3
+++ pdemo/configure.ac 3 May 2002 04:34:09 -0000
@@ -47,7 +47,7 @@
AC_SUBST([LIBTOOL_DEPS])
if ${CONFIG_SHELL} ./libtool --features | grep "enable static" >/dev/null; then
- STATIC=-static
+ STATIC=-all-static
else
STATIC=
fi
Index: tagdemo/Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/tagdemo/Makefile.am,v
retrieving revision 1.3
diff -u -u -r1.3 Makefile.am
--- tagdemo/Makefile.am 6 Jun 2001 14:53:29 -0000 1.3
+++ tagdemo/Makefile.am 3 May 2002 04:34:09 -0000
@@ -11,10 +11,12 @@
libfoo_la_SOURCES = foo.cpp
libfoo_la_LIBADD = $(LIBM)
+libfoo_la_LDFLAGS = -no-undefined
# Test some of the ILD support when using tagged configurations.
libbaz_la_SOURCES = baz.cpp
libbaz_la_LIBADD = libfoo.la
+libbaz_la_LDFLAGS = -no-undefined
noinst_HEADERS = foo.h baz.h
Index: tests/build-relink2.test
===================================================================
RCS file: /cvsroot/libtool/libtool/tests/build-relink2.test,v
retrieving revision 1.5
diff -u -u -r1.5 build-relink2.test
--- tests/build-relink2.test 5 Sep 2000 12:54:02 -0000 1.5
+++ tests/build-relink2.test 3 May 2002 04:34:09 -0000
@@ -11,7 +11,8 @@
. $srcdir/defs || exit 1
# Check that things are built.
-if test -f $prefix/lib/extra/libl3.la && cd ../depdemo && test -f l3/libl3.la;
then :
+if (test -f $prefix/lib/extra/libl3.la || test -f $prefix/lib/libl3.la) \
+ && cd ../depdemo && test -f l3/libl3.la; then :
else
echo "You must run depdemo-inst.test before $0" 1>&2
exit 77
With the patched automake-1.6.1, libtool (CVS 2002-05-02) as
patched, passes all tests but:
dry-run
mdemo-inst[mdemo-conf] (foo1.dll not found win32 popup)
hardcode
build-relink2 (***.dll not found win32 popups)
mdemo-inst[mdemo-shared] (foo1.dll not found win32 popup)
quote
dry-run:
-------------------
Sigh. We failed dry-run for ages, and then it started
working again in 20020202-1. Now somebody broke it.
mdemo-inst (mdemo-conf and mdemo-shared):
-------------------
modules are not installed in the path, nor are they in
the same directory as the executable. So, the test
fails because windows can't find the installed DLL.
This is a testing error, not a real error. Setting the
$PATH appropriately, and the test succeeds. Should we
install wrapper scripts into _inst/bin, or should
mdemo-inst.test explicitly set the PATH before attempting
to run the executable?
build-relink2:
-------------------
I fixed one bug, but another showed up: $PATH doesn't
get set properly when running this test...This test
used to get skipped on cygwin, but no longer?
quote:
-------------------
compile mode seems okay
install mode seems okay
link mode *always* fails -- like this:
"failed: mkdir .libs
gcc -o hell.exe -g -O -Wl,-someflag=test foo.o"
?? *mkdir* fails??
But it works fine in compile mode---
"passed: mkdir .libs
gcc -c "-DVAR= test " foo.c -DPIC -o .libs/foo.o
gcc -c "-DVAR= test " foo.c -o foo.o >/dev/null 2>&1"
OTHER NOTES:
-------------------
STATIC EXECUTABLES:
Note: I don't think static executables are actually being
linked statically, if there are import libs around to use...
The makefile calls libtool like this:
/bin/bash ./libtool --mode=link gcc -O2 -o hell_static.exe -static main.o
libhello.la
but libtool calls gcc like this:
gcc -O2 -o hell_static.exe main.o ./.libs/libhello.a
It drops the -static!
More investigation: libtool 'eats' the "-static" argument; you
have to feed "-all-static" to libtool, in order to convince it
to put "$link_static_flag" in the gcc command line. So, I changed
the appropriate configure.ac's to set STATIC=-all-static.
PASSED: build-relink
build-relink didn't get skipped like it used to be in 20020316-1.
We expect a failure here, and we got it -- so technically we PASSED
this test. However, the failure mode was a Win32 popup "procedure
entry point foo could not be located in the dynamic link library
cyghello-2.dll" -- requiring manual intervention to dismiss the
popup...
- Some fixes for cygwin,
Charles Wilson <=