Re: DESTDIR install on hppa-hpux
Hi Ralf, On Fri, 2009-06-12 at 21:57 +0200, Michael Haubenwallner wrote: Hmm. This does open a small security issue, no? That's precisely the reason we haven't gone this way before. Asking HP people (or more carefully reading the manpage) does help: The linker does have the +cdp flag, which allows for changing the linktime path of a library into something different being stored as fallback path into the binary. It does even work on hpux10.20 (ld B.10.37 here) although not mentioned in its manpage. Here's a patch that uses the +cdp linker flag to close the security issue with the fallback path encoded into the SOM binaries, by adding another libtool property 'fix_hardcoded_libdir_flag_spec', only used for hppa-hpux (32bit). It is configure-checked if compiler/linker do support this flag. This allows for hardcode_action=immediate and fast_install=yes, required for DESTDIR support. tests/deplibs-ident.at has to filter this flag, as it would lead to false positives. The same 12 tests as before are turned from SKIP/XFAIL to PASS on all the setups as before, with one exception: It is collect2 of gcc-3.0.1 on hppa-hpux10 here, which erroneously interprets -Wl,+cdp and fails to find libraries. So no tests do change their result in this setup. Thank you! /haubi/ diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index 6f44d35..f7d098d 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -3801,6 +3801,8 @@ func_mode_link () lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= +fix_hardcoded_libdir_flag= +fix_hardcoded_libdir_flag_ld= avoid_version=no dlfiles= @@ -5436,6 +5438,15 @@ func_mode_link () elif test $hardcode_shlibpath_var = no; then add_shlibpath=$dir add=-l$name + elif test -n $fix_hardcoded_libdir_flag_spec; then + add_dir=-L${absdir} + add=-l$name + if test ${linkmode} = prog test X${absdir} != X${libdir}; then + linkdir=$absdir + eval fix_hardcoded_libdir_flag=\\${fix_hardcoded_libdir_flag} ${fix_hardcoded_libdir_flag_spec}\ + # fix_hardcoded_libdir_flag_ld not needed, programs are linked with $CC + $lt_unset linkdir + fi else lib_linked=no fi @@ -5503,6 +5514,15 @@ func_mode_link () elif test $hardcode_minus_L = yes; then add_dir=-L$libdir add=-l$name + if test -n $inst_prefix_dir + test -f $inst_prefix_dir$libdir/$linklib + test -n ${fix_hardcoded_libdir_flag_spec}; then + linkdir=$inst_prefix_dir$libdir + add_dir=-L$linkdir + eval fix_hardcoded_libdir_flag=\\${fix_hardcoded_libdir_flag} ${fix_hardcoded_libdir_flag_spec}\ + eval fix_hardcoded_libdir_flag_ld=\\${fix_hardcoded_libdir_flag_ld} ${fix_hardcoded_libdir_flag_spec_ld}\ + $lt_unset linkdir + fi elif test $hardcode_shlibpath_var = yes; then case :$finalize_shlibpath: in *:$libdir:*) ;; diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4 index 5f24fab..9907f66 100644 --- a/libltdl/m4/libtool.m4 +++ b/libltdl/m4/libtool.m4 @@ -1905,6 +1905,7 @@ if test -n $_LT_TAGVAR(hardcode_libdir_flag_spec, $1) || # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test $_LT_TAGVAR(hardcode_shlibpath_var, $1) != no + test -z $_LT_TAGVAR(fix_hardcoded_libdir_flag_spec, $1) test $_LT_TAGVAR(hardcode_minus_L, $1) != no; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink @@ -4175,6 +4176,8 @@ m4_if([$1], [CXX], [ _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(fix_hardcoded_libdir_flag_spec, $1)= + _LT_TAGVAR(fix_hardcoded_libdir_flag_spec_ld, $1)= _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= @@ -4758,13 +4761,12 @@ _LT_EOF hpux10*) if test $GCC = yes test $with_gnu_ld = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags $fix_hardcoded_libdir_flag' else - _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags $fix_hardcoded_libdir_flag_ld' fi if test $with_gnu_ld = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir $fix_hardcoded_libdir_flag' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes
[PATCH] [cygwin|mingw] fix dlpreopen with --disable-static take 6
* libltdl/config/general.m4sh: Update copyright year. (func_tr_sh): New function. * libltdl/config/ltmain.m4sh (func_generate_dlsyms) [cygwin|mingw]: Obtain DLL name corresponding to import library by using value stored in unique variable libfile_$(transliterated implib name). If that fails, use $sharedlib_from_linklib_cmd to extract DLL name from import library directly. Also, properly extract dlsyms from the import library. (func_mode_link) [cygwin|mingw]: Prefer to dlpreopen DLLs over static libs when both are available. When dlpreopening DLLs, use linklib (that is, import lib) as dlpreopen file, rather than DLL. Store name of associated la file in unique variable libfile_$(transliterated implib name) for later use. (func_win32_libid): Accomodate pei-i386 import libs as well as pe-i386. (func_cygming_dll_for_implib): New function. (func_cygming_dll_for_implib_fallback): New function. (func_cygming_dll_for_implib_fallback_core): New function. (func_cygming_gnu_implib_p): New function. (func_cygming_ms_implib_p): New function. * libltdl/m4/libtool.m4 (_LT_CMD_GLOBAL_SYMBOLS): Adjust sed expressions for lt_cv_sys_global_symbol_to_c_name_address and lt_cv_sys_global_symbol_to_c_name_address_lib_prefix as trailing space after module name is optional. (_LT_LINKER_SHLIBS) [cygwin|mingw][C++]: Set exclude_expsyms correctly for $host. Simplify regular expression in export_symbols_cmds. (_LT_LINKER_SHLIBS) [cygwin|mingw|pw32][C]: Set exclude_expsyms correctly for $host. Enable export_symbols_cmds to identify DATA exports by _nm_ prefix. (_LT_CHECK_SHAREDLIB_FROM_LINKLIB): New macro sets sharedlib_from_linklib_cmd variable. (_LT_DECL_DLLTOOL): New macro ensures DLLTOOL is always set. --- Reposted without change from -take5, here: http://lists.gnu.org/archive/html/libtool-patches/2009-01/msg00232.html This patch has been in use in the cygwin distribution since 2009-02-20. libltdl/config/general.m4sh | 19 - libltdl/config/ltmain.m4sh | 226 +++ libltdl/m4/libtool.m4 | 62 +++- 3 files changed, 282 insertions(+), 25 deletions(-) diff --git a/libltdl/config/general.m4sh b/libltdl/config/general.m4sh index 4bc304c..e839070 100644 --- a/libltdl/config/general.m4sh +++ b/libltdl/config/general.m4sh @@ -1,6 +1,6 @@ m4_if([general.m4sh -- general shell script boiler plate -*- Autoconf -*- - Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. Written by Gary V. Vaughan, 2004 This file is part of GNU Cvs-utils. @@ -412,5 +412,22 @@ func_show_eval_locale () fi fi } + +# func_tr_sh +# Turn $1 into a string suitable for a shell variable name. +# Result is stored in $func_tr_sh_result. All characters +# not in the set a-zA-Z0-9_ are replaced with '_'. Further, +# if $1 begins with a digit, a '_' is prepended as well. +func_tr_sh () +{ + case $1 in + [0-9]* | *[!a-zA-Z0-9_]*) +func_tr_sh_result=`$ECHO $1 | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` +;; + * ) +func_tr_sh_result=$1 +;; + esac +} ]]) diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index 6f44d35..9353376 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -2007,10 +2007,49 @@ extern \C\ { func_verbose extracting global C symbols from \`$dlprefile' func_basename $dlprefile name=$func_basename_result - $opt_dry_run || { - eval '$ECHO : $name $nlist' - eval $NM $dlprefile 2/dev/null | $global_symbol_pipe '$nlist' - } + case $host in + *cygwin* | *mingw* | *cegcc* ) + # if an import library, we need to obtain dlname + if func_win32_import_lib_p $dlprefile; then + func_tr_sh $dlprefile + eval curr_lafile=\$libfile_$func_tr_sh_result + dlprefile_dlbasename= + if test -n $curr_lafile func_lalib_p $curr_lafile; then + # Use subshell, to avoid clobbering current variable values + dlprefile_dlname=`source $curr_lafile echo $dlname` + if test -n $dlprefile_dlname ; then + func_basename $dlprefile_dlname + dlprefile_dlbasename=$func_basename_result + else + # no lafile. user explicitly requested -dlpreopen import library. + eval '$sharedlib_from_linklib $dlprefile' + dlprefile_dlbasename=$sharedlib_from_linklib_result + fi + fi + $opt_dry_run || { + if test -n $dlprefile_dlbasename ; then + eval '$ECHO : $dlprefile_dlbasename $nlist' + else + func_warning Could not compute DLL name from $name + eval '$ECHO : $name $nlist' + fi + eval
[PATCH] [cygwin]: Add cross-compile support to cwrapper take 5
* libltdl/config/general.m4sh: Update copyright year. (func_tr_sh): New function. * libltdl/config/ltmain.m4sh (func_generate_dlsyms) [cygwin|mingw]: Obtain DLL name corresponding to import library by using value stored in unique variable libfile_$(transliterated implib name). If that fails, use $sharedlib_from_linklib_cmd to extract DLL name from import library directly. Also, properly extract dlsyms from the import library. (func_mode_link) [cygwin|mingw]: Prefer to dlpreopen DLLs over static libs when both are available. When dlpreopening DLLs, use linklib (that is, import lib) as dlpreopen file, rather than DLL. Store name of associated la file in unique variable libfile_$(transliterated implib name) for later use. (func_win32_libid): Accomodate pei-i386 import libs as well as pe-i386. (func_cygming_dll_for_implib): New function. (func_cygming_dll_for_implib_fallback): New function. (func_cygming_dll_for_implib_fallback_core): New function. (func_cygming_gnu_implib_p): New function. (func_cygming_ms_implib_p): New function. * libltdl/m4/libtool.m4 (_LT_CMD_GLOBAL_SYMBOLS): Adjust sed expressions for lt_cv_sys_global_symbol_to_c_name_address and lt_cv_sys_global_symbol_to_c_name_address_lib_prefix as trailing space after module name is optional. (_LT_LINKER_SHLIBS) [cygwin|mingw][C++]: Set exclude_expsyms correctly for $host. Simplify regular expression in export_symbols_cmds. (_LT_LINKER_SHLIBS) [cygwin|mingw|pw32][C]: Set exclude_expsyms correctly for $host. Enable export_symbols_cmds to identify DATA exports by _nm_ prefix. (_LT_CHECK_SHAREDLIB_FROM_LINKLIB): New macro sets sharedlib_from_linklib_cmd variable. (_LT_DECL_DLLTOOL): New macro ensures DLLTOOL is always set. -- This is a repost of the take 4 patch originally posted here: http://lists.gnu.org/archive/html/libtool-patches/2009-01/msg00232.html This patch has been in use in the cygwin distribution since 2009-02-20. I've rewritten the original patch notes from -take1...-take4, so that a more coherent story can be told, for folks just joining this thread or who have forgotten all the surrounding context... Another good summary (if I do say so myself) of the problem, and history, that the attached patch addresses can be found here: [CFT] libtool on nix-cygwin cross, with wine http://www.cygwin.com/ml/cygwin/2009-02/msg00555.html (Ignore the rest of the thread; there was not a single on-topic reply.) Definition: works, or for the cwrapper to work properly in this context means that you can, from the $build environment, execute the cwrapper program, and eventually the actual target executable will be successfully launched. In all known cases involving the cwrapper (e.g $host is win32-related -- except maybe cegcc but that's another issue), *compiling* in a cross environment with those $hosts always works just fine. It's launching the uninstalled target executables that is at issue throughout this post. Unix - mingw cross builds need special support when creating the cwrapper source code in order for the cwrapper to work properly under the wine environment. This was originally described here: http://lists.gnu.org/archive/html/libtool-patches/2008-04/msg00164.html (that patch is already part of libtool, in a modified form). However, the full explanation is: 1) On win32 $host we need an executable wrapper, rather than the normal shell script wrapper, for dynamically linked executables. This is because the automake rules' target is foo$(EXEEXT). a) it is a bad idea to lie to win32 OS by naming a file that is NOT a PE/COFF executable foo.exe so we can't just rename foo (the shell script) as foo.exe. So, because we need to support native builds on cygwin, mingw, and friends, we have to care about this case, and not simply emit the shell wrapper as foo$(EXEEXT). 2) We have long had this cwrapper. It used to coexist in the same directory with the shell script wrapper. The cwrapper would exec the shell wrapper, which did all the work, and then launched the actual target. a) This doesn't work for cygwin-1.5 where CYGWIN variable contains the flag transparent_exe. Since transparent_exe is now the default behavior for cygwin-1.7 (due to be released within 2 wks) this foo + foo.exe in same directory will very shortly be broken. b) So, a year or so ago, the cwrapper was modified to do all the work itself (setting PATH/LD_LIBRARY_PATH, etc), and to directly invoke the target. Similarly, libtool no longer creates the shell wrapper with the target's name (there is still a shell wrapper on these $hosts, but it goes in .libs/ and is named ltshwrapper_foo. This was the original goal, anyway, because it's just kinda silly to have two levels of wrappers to get to the target exe. c) One wrinkle: the cwrapper is a $host executable, not a $build one. So, for instance when $host=$mingw, the
Re: [PATCH] [cygwin]: Add cross-compile support to cwrapper take 5
Charles Wilson wrote: ... a long correct message but with the wrong changelog. sorry. Here's the correct changelog. - Refactor cwrapper cross-compile support; Add cygwin. * libltdl/m4/libtool.m4 (_LT_PATH_CONVERSION_FUNCTIONS): New function sets libtool variable $to_host_path_cmd, and employs cache. AC_SUBSTs $to_host_path_cmd, as well. (_LT_SETUP): Require it. * tests/testsuite.at: Ensure to_host_path_cmd is passed as a variable setting on the configure line for (new testsuite) tests. * Makefile.am: Ensure to_host_path_cmd is included in TEST_ENVIRONMENT so that it is passed to (old testsuite) tests. * libltdl/config/ltmain.m4sh (func_cygpath): New function. (func_init_to_host_pathlist_cmd): New function. (func_to_host_path): Refactored to... (now uses eval $to_host_path_cmd). (func_wine_to_win32_path): Here. New function. (func_msys_to_win32): Here. New function. (func_path_convert_check): Here. New function. (func_noop_path_convert): Here. New function. (func_msys_to_mingw_path_convert): Here. New function. (func_cygwin_to_mingw_path_convert): Here. New function. (func_nix_to_mingw_path_convert): Here. New function. (func_msys_to_cygwin_path_convert): New function. (func_nix_to_cygwin_path_convert): New function. (func_to_host_pathlist): Refactored to... (now uses eval $to_host_pathlist_cmd and func_init_to_host_pathlist_cmd). (func_pathlist_convert_check): Here. New function. (func_pathlist_front_back_pathsep): Here. New function. (func_wine_to_win32_pathlist): Here. New function. (func_noop_pathlist_convert): Here. New function. (func_msys_to_mingw_pathlist_convert): Here. New function. (func_cygwin_to_mingw_pathlist_convert): Here. New function. (func_nix_to_mingw_pathlist_convert): Here. New function. (func_msys_to_cygwin_pathlist_convert): New function. (func_nix_to_cygwin_pathlist_convert): New function.