Subject: incorrect sys_lib_search_path_spec with mingw cross compiler

From: Ozkan Sezer <[email-masked]>
Date: Tue, 10 Sep 2013 15:40:16 +0300

This patch by Charles Wilson went in in 2009 between libtool-2.2.6 and
2.2.8 is causing libtool to use incorrect sys_lib_search_path_spec with
mingw cross compiler:
http://lists.gnu.org/archive/html/libtool-patches/2009-06/msg00052.html
http://git.savannah.gnu.org/gitweb/?p=libtool.git;a=commitdiff;h=f0f99955cb283ead0817744921621d66c049709f

$ x86_64-w64-mingw32-gcc --print-search-dirs
install: /opt/W64_180676/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/
programs: =/opt/W64_180676/bin/../libexec/gcc/x86_64-w64-mingw32/4.5.4/:/opt/W64_180676/bin/../libexec/gcc/:/opt/W64_180676/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../../x86_64-w64-mingw32/bin/x86_64-w64-mingw32/4.5.4/:/opt/W64_180676/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../../x86_64-w64-mingw32/bin/
libraries: =/opt/W64_180676/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/:/opt/W64_180676/bin/../lib/gcc/:/opt/W64_180676/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../../x86_64-w64-mingw32/lib/x86_64-w64-mingw32/4.5.4/:/opt/W64_180676/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../../x86_64-w64-mingw32/lib/../lib64/:/opt/W64_180676/bin/../../cross_win64/mingw/lib/x86_64-w64-mingw32/4.5.4/:/opt/W64_180676/bin/../../cross_win64/mingw/lib/../lib64/:/opt/W64_180676/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../../x86_64-w64-mingw32/lib/:/opt/W64_180676/bin/../../cross_win64/mingw/lib/

With libtool-2.2.6 and older, I have this in libtool --config output:
sys_lib_search_path_spec="
/opt/W64_180676/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/
/opt/W64_180676/bin/../lib/gcc/
/opt/W64_180676/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../../x86_64-w64-mingw32/lib/x86_64-w64-mingw32/4.5.4/
/opt/W64_180676/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../../x86_64-w64-mingw32/lib/../lib64/
/opt/W64_180676/bin/../../cross_win64/mingw/lib/x86_64-w64-mingw32/4.5.4/
/opt/W64_180676/bin/../../cross_win64/mingw/lib/../lib64/
/opt/W64_180676/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../../x86_64-w64-mingw32/lib/
/opt/W64_180676/bin/../../cross_win64/mingw/lib/"

With libtool-2.2.8 and newer, including current git, it is like this:
sys_lib_search_path_spec="/opt/W64_180676/lib/gcc
/opt/W64_180676/x86_64-w64-mingw32/lib64 /opt/cross_win64/mingw/lib64
"

... which is incorrect: /opt/W64_180676/x86_64-w64-mingw32/lib64 does
exist, but it holds only gcc libs, whereas the required libs are under
/opt/W64_180676/x86_64-w64-mingw32/lib, therefore libtool -2.2.8 and
newer cannot build a dll with the following failure:

*** Warning: linker path does not have real file for library -lole32.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libole32 but no candidates were found. (...for file magic test)

*** Warning: linker path does not have real file for library -ldsound.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libdsound but no candidates were found. (...for file magic test)

*** Warning: linker path does not have real file for library -lwinmm.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libwinmm but no candidates were found. (...for file magic test)
*** The inter-library dependencies that have been dropped here will be
*** automatically added whenever a program is linked with this library
*** or is declared to -dlopen it.

.. only because it cannot find the libs. Reverting the above-mentioned
change makes it to work again.

--
O.S.