From 2fc9d079d637ba1abd1d1e1ab7fe5c1a59b8f785 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Fri, 19 Oct 2012 11:51:12 +0200 Subject: [PATCH] libtool: make func_win32_libid work when the name lister is MS dumpbin * m4/libtool.m4 (_LT_CHECK_MAGIC_METHOD) [MSVC]: Use func_win32_libid as file_magic_cmd when the name lister is MS dumpbin. (_LT_CMD_GLOBAL_SYMBOLS): Export the new veriable nm_interface to the libtool script. * build-aux/ltmain.in (func_cygming_gnu_implib_p) (func_cygming_ms_implib_p): Move up to before... (func_win32_libid): ...which now uses them to determine if the object is an import library when the nm_interface is "MS dumpbin". * NEWS: Update. Signed-off-by: Peter Rosin --- NEWS | 5 ++-- build-aux/ltmain.in | 71 +++++++++++++++++++++++++++------------------ m4/libtool.m4 | 5 ++-- 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/NEWS b/NEWS index ad1d8f96b..7f70eaf9e 100644 --- a/NEWS +++ b/NEWS @@ -55,8 +55,9 @@ NEWS - list of user-visible changes between releases of GNU Libtool (e.g. the ability to parse `var+=append') as $CONFIG_SHELL, libtool will now correctly fallback to using only vanilla shell features instead of failing with a parse at startup. - - Fix a bug in the wrapper for using Microsoft dumpbin as name lister - which could lead to broken symbol listings in some corner cases. + - Correctly recognize import libraries when Microsoft dumpbin is used + as the name lister. Also fix a bug in the dumpbin wrapper which could + lead to broken symbol listings in some corner cases. ** Important incompatible changes: diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in index bcfc04c01..ed4a4b155 100644 --- a/build-aux/ltmain.in +++ b/build-aux/ltmain.in @@ -2904,6 +2904,32 @@ static const void *lt_preloaded_setup() { fi } +# func_cygming_gnu_implib_p ARG +# This predicate returns with zero status (TRUE) if +# ARG is a GNU/binutils-style import library. Returns +# with nonzero status (FALSE) otherwise. +func_cygming_gnu_implib_p () +{ + $debug_cmd + + func_to_tool_file "$1" func_convert_file_msys_to_w32 + func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` + test -n "$func_cygming_gnu_implib_tmp" +} + +# func_cygming_ms_implib_p ARG +# This predicate returns with zero status (TRUE) if +# ARG is an MS-style import library. Returns +# with nonzero status (FALSE) otherwise. +func_cygming_ms_implib_p () +{ + $debug_cmd + + func_to_tool_file "$1" func_convert_file_msys_to_w32 + func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` + test -n "$func_cygming_ms_implib_tmp" +} + # func_win32_libid arg # return the library type of file 'arg' # @@ -2925,9 +2951,20 @@ func_win32_libid () # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then - func_to_tool_file "$1" func_convert_file_msys_to_w32 - win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | - $SED -n -e ' + case $nm_interface in + "MS dumpbin") + if func_cygming_ms_implib_p "$1" || + func_cygming_gnu_implib_p "$1" + then + win32_nmres=import + else + win32_nmres= + fi + ;; + *) + func_to_tool_file "$1" func_convert_file_msys_to_w32 + win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | + $SED -n -e ' 1,100{ / I /{ s|.*|import| @@ -2935,6 +2972,8 @@ func_win32_libid () q } }'` + ;; + esac case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; @@ -3033,32 +3072,6 @@ func_cygming_dll_for_implib_fallback_core () $SED -e '/^\./d;/^.\./d;q' } -# func_cygming_gnu_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is a GNU/binutils-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_gnu_implib_p () -{ - $debug_cmd - - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` - test -n "$func_cygming_gnu_implib_tmp" -} - -# func_cygming_ms_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is an MS-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_ms_implib_p () -{ - $debug_cmd - - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` - test -n "$func_cygming_ms_implib_tmp" -} - # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified diff --git a/m4/libtool.m4 b/m4/libtool.m4 index d02bd252b..e216f725c 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -3187,8 +3187,7 @@ mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. - # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. - if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then + if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else @@ -3835,6 +3834,8 @@ _LT_DECL([global_symbol_to_c_name_address], _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) +_LT_DECL([nm_interface], [lt_cv_nm_interface], [1], + [The name lister interface]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS -- 2.47.3