This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problems creating "-mno-cygwin" DLLs with libtool HACK (Sorry, Wrong Patch attached : FIXED).




Dave Korn wrote:

-----Original Message-----
From: Vladius [mailto:boxforsr@inbox.ru]





I have found a solution to hack this issue.
1.Goto usr/autotool/devel/bin/
2.Open "libtool" file with a text editor(vim).
3.Search for "postdeps" initialisation. ("postdeps=" string)
4.Remove "-lcygwin" initialisation literal string to the right.
5.Check out next variable assignment - "compiler_lib_search_path=".
6.change "i*86-pc-cygwin" to "i*86-pc-mingw" in all of its occurences to the right of varable assignment.


The resulting library created with libtool no longer depends on cygwin DLL.

Does anyone have a better solution? Maybe I just missed smth allready known or implemented. Please, let me know.




I was looking through that file as well, but I see you got there first.

 Don't forget that there's another version of libtool in
/usr/autotool/stable/bin, and that you may need to patch that one as well.
(/usr/libtool is a wrapper script that chooses the appropriate libtool version
according to the autoconf version in use).

 The fix seems ok to me, but it would be better if you could fix it so that it
only excludes -lcygwin when the -mno-cygwin flag is actually present, by testing
for it.  So maybe you want to use something a bit more like this:

--------------------------<snip!>--------------------------
--- libtool.orig	2005-02-01 17:39:45.797711300 +0000
+++ libtool	2005-02-01 17:52:42.458335100 +0000
@@ -7120,11 +7120,25 @@ predeps=""

# Dependencies to place after the objects being linked to create a
# shared library.
-postdeps="-lstdc++ -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32
-lgcc"
+case $compiler_flags in
+ *mno-cygwin*) # Exclude -lcygwin from mingw builds
+  postdeps="-lstdc++ -lgcc -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc"
+  ;;
+ *) # Default - assume cygwin required.
+  postdeps="-lstdc++ -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32
-lgcc"
+  ;;
+esac

# The library search path used internally by the compiler when linking
# a shared library.
-compiler_lib_search_path="-L/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3
-L/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../.."
+case $compiler_flags in
+ *mno-cygwin*) # Don't use cygwin link libraries for mingw builds...
+  compiler_lib_search_path="-L/usr/lib/gcc-lib/i686-pc-mingw/3.3.3
-L/usr/lib/gcc-lib/i686-pc-mingw/3.3.3/../../.."
+  ;;
+ *) # Default - assume cygwin required.
+  compiler_lib_search_path="-L/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3
-L/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../.."
+  ;;
+esac

# Method to check whether dependent libraries are shared objects.
deplibs_check_method="file_magic ^x86 archive import|^x86 DLL"
--------------------------<snip!>--------------------------

But note that I haven't actually tested this....

 Hmm.  I think you probably also need to change a few others in the same way as
well.  Doing a search for "-cygwin/" in the file, I found these other
definitions:

--------------------------<snip!>--------------------------
# The linker used to build libraries.
LD="/usr/i686-pc-cygwin/bin/ld.exe"
--------------------------<snip!>--------------------------

 Found that one in three places, actually, but I would guess it's
less-than-critical if we choose the wrong linker.  Might mess with default
search paths, if you were relying on them.

--------------------------<snip!>--------------------------
# Dependencies to place before the objects being linked to create a
# shared library.
predep_objects="/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/crtbegin.o"

# Dependencies to place after the objects being linked to create a
# shared library.
postdep_objects="/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/crtend.o"
--------------------------<snip!>--------------------------

 These two are just before the section I quoted above, and it seems almost
certain to me (again, without having tried or tested it) that if you want a
mingw compilation, you should be using the mingw runtime startup and termination
modules.  So the same sort of case statement as I used above would work again.



cheers, DaveK


   Im not familiar with libtool internals, since I didnt write this
script, and I couldnt find any other way to extract "-mno-cygwin"
specification but to use "$@".
"compiler_flags" variable was empty in those places I tried to use. If
anyone can make this script patch look better, please let me know.
"-nostdlib" was excluded from compilation because it appeared to work
like that in a self-contained way => postdep and predep objects are no
longer need to be specifed. I might made a mistake by cutting them off
but everything works fine for me, however unpleasant feeling, that
"-nostdlib" was specified not just for fun, still pursuits me =)



1713d1712
<
1846c1845,1846
< ;;
---
> ;;
>
1850a1851
>
2321d2321
<
4874d4873
<
7085,7094c7084
<
<
< case "$@" in
< *mno-cygwin*) # MinGW trivial compilation
< archive_cmds="\$CC -shared \$predep_objects \$libobjs \$deplibs \$postdep_objects \$compiler_flags -o \$output_objdir/\$soname \${wl}--image-base=0x10000000 \${wl}--out-implib,\$lib";;
< *) #Default - Assume cygwin.
< archive_cmds="\$CC -shared -nostdlib \$predep_objects \$libobjs \$deplibs \$postdep_objects \$compiler_flags -o \$output_objdir/\$soname \${wl}--image-base=0x10000000 \${wl}--out-implib,\$lib";;
< esac
<
<
---
> archive_cmds="\$CC -shared -nostdlib \$predep_objects \$libobjs \$deplibs \$postdep_objects \$compiler_flags -o \$output_objdir/\$soname \${wl}--image-base=0x10000000 \${wl}--out-implib,\$lib"
7121,7126c7111
< case "$@" in
< *mno-cygwin*) # -mno-cygwin was specified.
< predep_objects="";;
< *) # Assume Cygwin.
< predep_objects="/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/crtbegin.o";;
< esac
---
> predep_objects="/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/crtbegin.o"
7130,7136c7115
< case "$@" in
< *mno-cygwin*)
< postdep_objects="";;
< *)
< postdep_objects="/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/crtend.o";;
< esac
<
---
> postdep_objects="/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/crtend.o"
7144,7149c7123
< case "$@" in
< *mno-cygwin*)
< postdeps="";;
< *)
< postdeps="-lstdc++ -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc";;
< esac
---
> postdeps="-lstdc++ -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc"
7153,7160c7127
< case "$@" in
< *mno-cygwin*)
< compiler_lib_search_path="";;
< *)
< compiler_lib_search_path="-L/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3 -L/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../..";;
< esac
<
<
---
> compiler_lib_search_path="-L/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3 -L/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../.."


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]