A bug in get_board_flags fin ld/testsuite/lib/ld-lib.exp

Jan Dubiec jdx@o2.pl
Sun Aug 16 09:12:37 GMT 2026


What is the get_board_flags procedure in ld/testsuite/lib/ld-lib.exp 
supposed to do? Return the cflags and ldflags defined in the board 
description file, right? But it doesn't seem to do that.

Unfortunately, I don't know enough about DejaGnu's target/board handling 
to figure out how this should be fixed, so I'd appreciate some help from 
someone more experienced. Some information is provided below.

/J.D.

Adding a few simple diagnostic messages:

diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index 25722d86f52..4438a28dcac 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -210,6 +210,12 @@ proc get_board_flags {} {
      global board_cflags
      global board_ldflags

+    verbose "=== get_board_flags ===" 0
+    verbose "script = [info script]" 0
+    verbose "target_info name = '[target_info name]'" 0
+    verbose "arm-qemu cflags = '[board_info arm-qemu cflags]'" 0
+    verbose "arm-qemu ldflags = '[board_info arm-qemu ldflags]'" 0
+
      if [board_info [target_info name] exists cflags] {
         set board_cflags " [board_info [target_info name] cflags]"
      } else {


This produces the following output:

=== get_board_flags ===
script = /mnt/Works/binutils/ld/testsuite/config/default.exp
target_info name = ''
arm-qemu cflags = '  --specs=rdimon.specs'
arm-qemu ldflags = ' -L/mnt/Works/xcomp/build-binutils-arm-linux/ld'

This seems to explain the problem: the board_info array contains the 
expected information, but [target_info name] is empty when 
get_board_flags is called. As a result, get_board_flags returns empty 
cflags and ldflags.

I run the tests with:
make -k check-ld RUNTESTFLAGS="--target_board=arm-qemu --verbose=3 
unique.exp"

Here is the beginning of the log:
		=== ld tests ===

setting trap for SIGINT to interrupted by user
setting trap for SIGQUIT to interrupted by user
setting trap for SIGTERM to terminated
dirlist is /usr/share/dejagnu/baseboards
pushing config for build, name is jdxpc
dirlist is /usr/share/dejagnu/baseboards
pushing config for host, name is jdxpc
target list is arm-qemu
Schedule of variations:
     arm-qemu

target is arm-qemu
Running target arm-qemu
dirlist is /usr/share/dejagnu/baseboards/jdxpc /usr/share/dejagnu/baseboards
Using /usr/share/dejagnu/baseboards/arm-qemu.exp as board description 
file for target.
Using /usr/share/dejagnu/config/sim.exp as generic interface file for 
target.
Using /usr/share/dejagnu/baseboards/basic-sim.exp as board description 
file for target.
Using simulator qemu-system-arm

Transforming gcc to arm-eabi-gcc
compiler is arm-eabi-gcc
GCC path is .
No newlib support for this target
Looking for /mnt/Works/xcomp/sysroot-linux/bin/../arm-eabi/./newlib
No newlib support for this target
Using /mnt/Works/binutils/ld/testsuite/config/default.exp as 
tool-and-target-specific interface file.
[...]


check_compiler_available is called from default.exp, and the call chain is:

check_compiler_available
     -> make_dummy_target_executable
         -> get_board_flags

So it appears that get_board_flags is being called while default.exp is 
being sourced, before target_info name has been initialized.


More information about the Binutils mailing list