aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2024-07-26 14:26:29 +0100
committerAndrew Burgess <aburgess@redhat.com>2024-07-26 15:36:29 +0100
commit4a2b9808fc8e6d7baf400b0ab7a7d180f9493e36 (patch)
treeb185d626510ee30c013e847447e3a0021b8dc6c6 /gdb/testsuite
parentb8b1a4388835bf2899bb0cc148db42a2c32e2af6 (diff)
downloadgdb-4a2b9808fc8e6d7baf400b0ab7a7d180f9493e36.zip
gdb-4a2b9808fc8e6d7baf400b0ab7a7d180f9493e36.tar.gz
gdb-4a2b9808fc8e6d7baf400b0ab7a7d180f9493e36.tar.bz2
gdb/testsuite: fix build-id compile option when used with clang
It was pointed out in this message: https://inbox.sourceware.org/gdb-patches/5d7a514b-5dad-446f-a021-444ea88ecf07@redhat.com That the test gdb.base/build-id-seqno.exp I added recently was FAILing when using Clang as the compiler. The problem was that I had failed to add 'build-id' as a compile option in the call to build_executable within the test script. For GCC this is fine as build-ids are included by default. For Clang though this meant the build-id was not included and the test would fail. So I added build-id to the compiler options.... and the test still didn't pass! Now the test fails to compile and I see this error from the compiler: gdb compile failed, clang-15: warning: -Wl,--build-id: 'linker' \ input unused [-Wunused-command-line-argument] It turns out that the build-id compile option causes our gdb.exp to add the '-Wl,--build-id' option into the compiler flags, which means its used when building the object file AND during the final link. However this option is unnecessary when creating the object file and Clang warns about this, which causes the build to fail. The solution is to change gdb.exp, instead of adding the build-id flags like this: lappend new_options "additional_flags=-Wl,--build-id" we should instead add them like: lappend new_options "ldflags=-Wl,--build-id" Now the flag is only appended during the link phase and Clang is happy. The gdb.base/build-id-seqno.exp test now passes with Clang. The same problem (adding to additional_flags instead of ldflags) exists for the no-build-id compile option, so I've fixed that too. While investigating this I also spotted two test scripts, gdb.base/index-cache.exp and gdb.dwarf2/per-bfd-sharing.exp which were setting ldflag directly rather than using the build-id compile option so I've updated these two tests to use the compile option which I think is neater. I've checked that all these tests still pass with both GCC and Clang. There should be no changes in what is actually tested after this commit. Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.base/build-id-seqno.exp3
-rw-r--r--gdb/testsuite/gdb.base/index-cache.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp2
-rw-r--r--gdb/testsuite/lib/gdb.exp4
4 files changed, 6 insertions, 5 deletions
diff --git a/gdb/testsuite/gdb.base/build-id-seqno.exp b/gdb/testsuite/gdb.base/build-id-seqno.exp
index fba8a8d..9566933 100644
--- a/gdb/testsuite/gdb.base/build-id-seqno.exp
+++ b/gdb/testsuite/gdb.base/build-id-seqno.exp
@@ -29,7 +29,8 @@ require {!is_remote host}
standard_testfile
-if {[build_executable "failed to prepare" $testfile $srcfile] == -1} {
+if {[build_executable "failed to prepare" $testfile $srcfile \
+ {debug build-id}] == -1} {
return -1
}
diff --git a/gdb/testsuite/gdb.base/index-cache.exp b/gdb/testsuite/gdb.base/index-cache.exp
index 0e19bfb..af64faa 100644
--- a/gdb/testsuite/gdb.base/index-cache.exp
+++ b/gdb/testsuite/gdb.base/index-cache.exp
@@ -19,7 +19,7 @@
standard_testfile .c -2.c
if { [build_executable "failed to prepare" $testfile [list $srcfile $srcfile2] \
- {debug ldflags=-Wl,--build-id}] } {
+ {debug build-id}] } {
return
}
diff --git a/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp b/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp
index ef1ed19..7df68a9 100644
--- a/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp
+++ b/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp
@@ -19,7 +19,7 @@
standard_testfile
if { [build_executable "failed to prepare" $testfile $srcfile \
- {debug ldflags=-Wl,--build-id}] == -1 } {
+ {debug build-id}] == -1 } {
return
}
set host_binfile [gdb_remote_download host $binfile]
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index dfe19c9..e5cacef 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5469,12 +5469,12 @@ proc gdb_compile {source dest type options} {
# enable it now.
if {[lsearch -exact $options build-id] > 0
&& [test_compiler_info "clang-*"]} {
- lappend new_options "additional_flags=-Wl,--build-id"
+ lappend new_options "ldflags=-Wl,--build-id"
}
# If the 'no-build-id' option is used then disable the build-id.
if {[lsearch -exact $options no-build-id] > 0} {
- lappend new_options "additional_flags=-Wl,--build-id=none"
+ lappend new_options "ldflags=-Wl,--build-id=none"
}
# Sanity check. If both 'build-id' and 'no-build-id' are used