]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Fix regression in step-indirect-call-thunk.exp with gcc 7
authorTom de Vries <tdevries@suse.de>
Mon, 18 Jul 2022 04:13:45 +0000 (06:13 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 18 Jul 2022 04:13:45 +0000 (06:13 +0200)
Since commit 43127ae5714 ("Fix gdb.base/step-indirect-call-thunk.exp") I run
into:
...
gdb compile failed, gcc: error: unrecognized command line option \
  '-fcf-protection=none'; did you mean '-flto-partition=none'?
UNTESTED: gdb.base/step-indirect-call-thunk.exp: failed to prepare
...

The problem is that -fcf-protection is supported starting gcc 8, but I'm using
system gcc 7.5.0.

Fix this by only adding -fcf-protection=none for gcc 8 and later.

Tested on x86_64-linux, with gcc 7.5.0, 8.2.1 and 12.1.1.

gdb/testsuite/gdb.base/step-indirect-call-thunk.exp
gdb/testsuite/lib/gdb.exp

index 7c1b53c99bee7010cdc87499d1ed9305d635c2a7..c4f69adc9b24829321dc6f81d6759a19b91fe21d 100644 (file)
@@ -19,7 +19,11 @@ if { ![istarget "x86*"] } {
     return
 }
 
-set cflags "-mindirect-branch=thunk -mfunction-return=thunk -fcf-protection=none"
+set cflags "-mindirect-branch=thunk -mfunction-return=thunk"
+
+if { [gcc_major_version] >= 8 } {
+    append cflags " -fcf-protection=none"
+}
 if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
         [list debug "additional_flags=$cflags"]] } {
     return -1
index 698dd14504ebcab7a6225abc5bcd851e61a9c908..5d6f1266b0fca041dab782b5b713e228c5edc8a0 100644 (file)
@@ -8529,6 +8529,17 @@ gdb_caching_proc supports_gnuc {
     return [gdb_simple_compile $me $src object ""]
 }
 
+# Return 1 if compiler supports __GNUC__, otherwise return 0.
+gdb_caching_proc supports_gnuc {
+    set me "supports_gnuc"
+    set src {
+       #ifndef __GNUC__
+       #error "No gnuc"
+       #endif
+    }
+    return [gdb_simple_compile $me $src object ""]
+}
+
 # Return 1 if target supports mpx, otherwise return 0.
 gdb_caching_proc have_mpx {
     global srcdir