Hi,

This fixes the following error for arm-none-eabi (probably other targets too):

ERROR: gcc.dg/builtin-pi-linkage.c: error executing dg-final: arm-none-eabi-nm: 
builtin-pi-linkage.o: plugin needed to handle lto object

Ok for trunk?

Kind regards,
Torbjörn

--

Find gcc-nm alongside the compiler under test instead of searching
the build tree for nm. This ensures that liblto_plugin.so is found
automatically when available, fixing the "plugin needed to handle
lto object" error for LTO tests like gcc.dg/builtin-pi-linkage.c.
Allow GCC_NM_UNDER_TEST to override the tool.

This follows the approach used for gcc-ar in r16-7327-gc9addbc79ac0f9.

gcc/testsuite/ChangeLog:

        * lib/gcc-dg.exp (scan-symbol-common): Use gcc-nm and honor
        GCC_NM_UNDER_TEST.

Signed-off-by: Torbjörn SVENSSON <[email protected]>
---
 gcc/testsuite/lib/gcc-dg.exp | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 9f183259257..bdd74d132c1 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1394,8 +1394,8 @@ proc gdb-exists { args } {
 # Argument 0 is the regexp to match.
 # Argument 1 handles expected failures and the like
 proc scan-symbol-common { scan_directive args } {
-    global nm
-    global base_dir
+    global GCC_UNDER_TEST
+    global GCC_NM_UNDER_TEST
 
     # Access variable from gcc-dg-test-1 or lto-execute.
     upvar 3 output_file output_file
@@ -1409,15 +1409,20 @@ proc scan-symbol-common { scan_directive args } {
        }
     }
 
-    # Find nm like we find g++ in g++.exp.
-    if ![info exists nm]  {
-       set nm [findfile $base_dir/../../../binutils/nm \
-               $base_dir/../../../binutils/nm \
-               [findfile $base_dir/../../nm $base_dir/../../nm \
-                     [findfile $base_dir/nm $base_dir/nm \
-                      [transform nm]]]]
-       verbose -log "nm is $nm"
+    # For now find gcc-nm in the same directory as $GCC_UNDER_TEST, unless
+    # GCC_NM_UNDER_TEST is defined.
+
+    if ![info exists GCC_NM_UNDER_TEST] {
+       if { ![is_remote host] && [string match "*/*" [lindex $GCC_UNDER_TEST 
0]] } {
+           set nm_cmd [file dirname [lindex $GCC_UNDER_TEST 
0]]/[gcc-transform-out-of-tree gcc-nm]
+       } else {
+           set nm_cmd [gcc-transform-out-of-tree gcc-nm]
+       }
+       set nm_cmd "$nm_cmd [lrange $GCC_UNDER_TEST 1 end]"
+    } else {
+       set nm_cmd $GCC_NM_UNDER_TEST
     }
+    verbose -log "nm is $nm_cmd"
 
     set output_file "[glob -nocomplain $output_file]"
     if { $output_file == "" } {
@@ -1425,7 +1430,7 @@ proc scan-symbol-common { scan_directive args } {
        return
     }
 
-    set fd [open "| $nm $output_file" r]
+    set fd [open "| $nm_cmd $output_file" r]
     set text [read $fd]
     close $fd
 
-- 
2.43.0

Reply via email to