# 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}"
}
}