diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 219ff3b92846b809f6a802391c8c3925359dfde8..64a00be0399e08667f103b25e2649c22bdccfeb0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2019-12-22 Maciej W. Rozycki <macro@wdc.com> + + * lib/gcc-defs.exp (gcc-set-multilib-library-path): Use + `-print-file-name=' to determine the multilib root directory. + Use `remote_exec host' rather than `exec' to invoke the + compiler. + 2019-12-21 Thomas Schwinge <thomas@codesourcery.com> PR fortran/93026 diff --git a/gcc/testsuite/lib/gcc-defs.exp b/gcc/testsuite/lib/gcc-defs.exp index 945b48afa398e37dbeb96d7824f1e94a96ddfa10..67f0883e7640ec3cdf46a0c3e75c1f71002a6767 100644 --- a/gcc/testsuite/lib/gcc-defs.exp +++ b/gcc/testsuite/lib/gcc-defs.exp @@ -324,29 +324,44 @@ proc dg-additional-files-options { options source } { # for COMPILER, including multilib directories. proc gcc-set-multilib-library-path { compiler } { - global rootme + set shlib_ext [get_shlib_extension] + set options [lrange $compiler 1 end] + set compiler [lindex $compiler 0] - # ??? rootme will not be set when testing an installed compiler. - # In that case, we should perhaps use some other method to find - # libraries. - if {![info exists rootme]} { + set libgcc_s_x [remote_exec host "$compiler" \ + "$options -print-file-name=libgcc_s.${shlib_ext}"] + if { [lindex $libgcc_s_x 0] == 0 \ + && [set libgcc_s_dir [file dirname [lindex $libgcc_s_x 1]]] != "" } { + set libpath ":${libgcc_s_dir}" + } else { return "" } - set libpath ":${rootme}" - set options [lrange $compiler 1 end] - set compiler [lindex $compiler 0] - if { [is_remote host] == 0 && [which $compiler] != 0 } { - foreach i "[eval exec $compiler $options --print-multi-lib]" { + set multi_dir_x [remote_exec host "$compiler" \ + "$options -print-multi-directory"] + set multi_lib_x [remote_exec host "$compiler" \ + "$options -print-multi-lib"] + if { [lindex $multi_dir_x 0] == 0 && [lindex $multi_lib_x 0] == 0 } { + set multi_dir [string trim [lindex $multi_dir_x 1]] + set multi_lib [string trim [lindex $multi_lib_x 1]] + if { "$multi_dir" == "." } { + set multi_root "$libgcc_s_dir" + } else { + set multi_match [string last "/$multi_dir" "$libgcc_s_dir"] + if { "$multi_match" < 0 } { + return $libpath + } + set multi_root [string range "$libgcc_s_dir" \ + 0 [expr $multi_match - 1]] + } + foreach i "$multi_lib" { set mldir "" regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir set mldir [string trimright $mldir "\;@"] - if { "$mldir" == "." } { + if { "$mldir" == "$multi_dir" } { continue } - if { [llength [glob -nocomplain ${rootme}/${mldir}/libgcc_s*.so.*]] >= 1 } { - append libpath ":${rootme}/${mldir}" - } + append libpath ":${multi_root}/${mldir}" } }