We currently have two copies of target-libpath.exp in the tree under gcc/testsuite/lib and libffi/testsuite/lib. It was originally pulled into the libffi project (from downstream gcc) in 2009 (https://github.com/libffi/libffi/commit/5cbe2058c128e848446ae79fe15ee54260a90559). Then in 2012, Anthony Green (from libffi) modified it to correct this Windows problem (and thank you: https://github.com/libffi/libffi/commit/bd78c9c3311244dd5f877c915b0dff91621dd253). In 2015, this file got pulled from upstream libffi back into gcc, thus beginning two separate development paths (https://github.com/gcc-mirror/gcc/commit/89d8a412de548b218cf7c967e65ad98bceb1ed4e).
This patch merges the changes from libffi upstream which correctly solve the Windows DLL load path problem in set_ld_library_path_env_vars and restore_ld_library_path_env_vars, thus fixing most PR79867. However, there is still incorrect behaviour in DejaGNU's unix_load that should eventually be adddressed, although I cannot yet point to a specific failure that it is causing. Ultimately, I think that this functionality should be moved upstream to DejaGNU where it can be managed more cleanly in board config files, but we'll have to keep this code in gcc for when DejaGNU doesn't have set/restore or push/pop libpath functionality. Signed-off-by: Daniel Santos <daniel.san...@pobox.com> --- gcc/testsuite/lib/target-libpath.exp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gcc/testsuite/lib/target-libpath.exp b/gcc/testsuite/lib/target-libpath.exp index 9b3e201ed68..b6d01b31016 100644 --- a/gcc/testsuite/lib/target-libpath.exp +++ b/gcc/testsuite/lib/target-libpath.exp @@ -23,6 +23,7 @@ set orig_shlib_path_saved 0 set orig_ld_library_path_32_saved 0 set orig_ld_library_path_64_saved 0 set orig_dyld_library_path_saved 0 +set orig_path_saved 0 set orig_gcc_exec_prefix_saved 0 set orig_gcc_exec_prefix_checked 0 @@ -55,6 +56,7 @@ proc set_ld_library_path_env_vars { } { global orig_ld_library_path_32_saved global orig_ld_library_path_64_saved global orig_dyld_library_path_saved + global orig_path_saved global orig_gcc_exec_prefix_saved global orig_gcc_exec_prefix_checked global orig_ld_library_path @@ -63,6 +65,7 @@ proc set_ld_library_path_env_vars { } { global orig_ld_library_path_32 global orig_ld_library_path_64 global orig_dyld_library_path + global orig_path global orig_gcc_exec_prefix global env @@ -110,6 +113,10 @@ proc set_ld_library_path_env_vars { } { set orig_dyld_library_path "$env(DYLD_LIBRARY_PATH)" set orig_dyld_library_path_saved 1 } + if [info exists env(PATH)] { + set orig_path "$env(PATH)" + set orig_path_saved 1 + } } # We need to set ld library path in the environment. Currently, @@ -164,6 +171,13 @@ proc set_ld_library_path_env_vars { } { } else { setenv DYLD_LIBRARY_PATH "$ld_library_path" } + if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } { + if { $orig_path_saved } { + setenv PATH "$ld_library_path:$orig_path" + } else { + setenv PATH "$ld_library_path" + } + } verbose -log "LD_LIBRARY_PATH=[getenv LD_LIBRARY_PATH]" verbose -log "LD_RUN_PATH=[getenv LD_RUN_PATH]" @@ -201,12 +215,14 @@ proc restore_ld_library_path_env_vars { } { global orig_ld_library_path_32_saved global orig_ld_library_path_64_saved global orig_dyld_library_path_saved + global orig_path_saved global orig_ld_library_path global orig_ld_run_path global orig_shlib_path global orig_ld_library_path_32 global orig_ld_library_path_64 global orig_dyld_library_path + global orig_path global env restore_gcc_exec_prefix_env_var @@ -245,6 +261,11 @@ proc restore_ld_library_path_env_vars { } { } elseif [info exists env(DYLD_LIBRARY_PATH)] { unsetenv DYLD_LIBRARY_PATH } + if { $orig_path_saved } { + setenv PATH "$orig_path" + } elseif [info exists env(PATH)] { + unsetenv PATH + } } ####################################### -- 2.11.0