[gdb/testsuite] Handle missing gold linker in gdb.base/morestack.exp
authorTom de Vries <tdevries@suse.de>
Mon, 13 Jul 2020 12:14:47 +0000 (14:14 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 13 Jul 2020 12:14:47 +0000 (14:14 +0200)
When running test-case gdb.base/morestack.exp without the gold linker
installed, we run into:
...
Running src/gdb/testsuite/gdb.base/morestack.exp ...
gdb compile failed, collect2: fatal error: cannot find 'ld'
compilation terminated.
FAIL: gdb.base/morestack.exp: continue

                === gdb Summary ===

nr of expected passes            1
nr of unexpected failures        1
nr of untested testcases         1
...

The test-case needs the gold linker to run correctly (as explained in commit
b8d38ee425 "testsuite: Fix false FAIL for gdb.base/morestack.exp"), but
only prefers it, and doesn't require it.

Fix this by requiring the gold linker in the test-case.  Furthermore, silence
the compilation error by introducing a caching proc have_fuse_ld_gold and
using it in this and other test-cases that use -fuse-ld=gold.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-07-13  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (have_fuse_ld_gold): New caching proc.
* gdb.base/gcore-tls-pie.exp: Use have_fuse_ld_gold.
* gdb.base/gold-gdb-index.exp: Same.
* gdb.base/morestack.exp: Same.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/gcore-tls-pie.exp
gdb/testsuite/gdb.base/gold-gdb-index.exp
gdb/testsuite/gdb.base/morestack.exp
gdb/testsuite/lib/gdb.exp

index ec0f8322e32722d76b3ddc0cc377cfeb2bea69f9..91a666ac3bede060fc202284588591884ed6fa3e 100644 (file)
@@ -1,3 +1,10 @@
+2020-07-13  Tom de Vries  <tdevries@suse.de>
+
+       * lib/gdb.exp (have_fuse_ld_gold): New caching proc.
+       * gdb.base/gcore-tls-pie.exp: Use have_fuse_ld_gold.
+       * gdb.base/gold-gdb-index.exp: Same.
+       * gdb.base/morestack.exp: Same.
+
 2020-07-11  Daniel Xu  <dxu@dxuuu.xyz>
 
        PR rust/26121
index 87399abfd8e44d6d84886b663321f437d10af3d3..c9386c0620fddb0e40095f7a2f59877645a4e6fb 100644 (file)
 
 standard_testfile
 
+if { [have_fuse_ld_gold] == 0} {
+    return -1
+}
+
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug additional_flags=-fpie "ldflags=-pie -fuse-ld=gold"}]} {
     return -1
 }
index e42bf439dd585f510698c3a7c62f18a63dd293b3..22a733af398c8f461999e939cb236588ab222781 100644 (file)
 
 standard_testfile .c gold-gdb-index-2.c
 
+if { [have_fuse_ld_gold] == 0} {
+    return -1
+}
+
 if {[prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" \
         {debug c++ additional_flags=-fuse-ld=gold \
              additional_flags=-Wl,--gdb-index \
index 2ea826c48068873c1848e47f131d4b3476510fdf..95ec9adc62bbf4aef553df614811aad8709fc068 100644 (file)
@@ -21,13 +21,17 @@ if {$gcc_compiled == 0} {
     return -1
 }
 
+if { [have_fuse_ld_gold] == 0} {
+    return -1
+}
+
 standard_testfile
 
 # -fuse-ld=gold is used for calling printf code built without -fsplit-stack
 # which could crash otherwise.  See GCC documentation of -fsplit-stack.
 set opts "additional_flags=-fsplit-stack"
-if { [prepare_for_testing "failed to prepare" ${testfile} $srcfile [list $opts additional_flags=-fuse-ld=gold]] \
-     && [prepare_for_testing "failed to prepare" ${testfile} $srcfile $opts] } {
+if { [prepare_for_testing "failed to prepare" ${testfile} $srcfile \
+         [list $opts additional_flags=-fuse-ld=gold]] } {
     return -1
 }
 
index b0faf622a9e6426a9cb5d38eee021fd587e3231d..78dae17b0c7c42929674b9103b4c648d264b50eb 100644 (file)
@@ -7456,5 +7456,13 @@ proc gdb_note { message } {
     verbose -- "NOTE: $message" 0
 }
 
+# Return 1 if compiler supports -fuse-ld=gold, otherwise return 0.
+gdb_caching_proc have_fuse_ld_gold {
+    set me "have_fuse_ld_gold"
+    set flags "additional_flags=-fuse-ld=gold"
+    set src { int main() { return 0; } }
+    return [gdb_simple_compile $me $src executable $flags]
+}
+
 # Always load compatibility stuff.
 load_lib future.exp
This page took 0.042266 seconds and 4 git commands to generate.