]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Fix gdb.base/enum_cond.exp on arm-linux
authorTom de Vries <tdevries@suse.de>
Tue, 18 Mar 2025 15:22:02 +0000 (16:22 +0100)
committerTom de Vries <tdevries@suse.de>
Tue, 18 Mar 2025 15:22:02 +0000 (16:22 +0100)
On arm-linux, I run into:
...
gdb compile failed, ld: warning: enum_cond.o uses variable-size enums yet \
  the output is to use 32-bit enums; use of enum values across objects may fail
UNTESTED: gdb.base/enum_cond.exp: failed to compile
...

Fix this by using -nostdlib.

Tested on arm-linux and x86_64-linux.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/testsuite/gdb.base/enum_cond.c
gdb/testsuite/gdb.base/enum_cond.exp
gdb/testsuite/lib/gdb.exp

index 35e126aed45a86c23556af05fdaaea569a1011ca..df8830f0c9e042790169a992f978ee8e6980f49a 100644 (file)
@@ -46,3 +46,19 @@ main (void)
   return 0;
 }
 
+void
+exit (int status)
+{
+#if HAVE_BUILTIN_TRAP
+  __builtin_trap ();
+#endif
+  while (1)
+    ;
+}
+
+void
+_start (void)
+{
+  main ();
+  exit (0);
+}
index 3ee90f8721f805c21313b96f74a5bda8032df4ed..d58da4796fe042fb413b57d5361c221448547d6c 100644 (file)
 
 standard_testfile .c
 
-set opts [list debug additional_flags=-fshort-enums]
+set opts {}
+lappend opts debug
+lappend opts additional_flags=-fshort-enums
+# Without -nostdlib, on arm we run into:
+#
+#   ld: warning: enum_cond.o uses variable-size enums yet the output is to use
+#     32-bit enums; use of enum values across objects may fail
+#
+# due to conflicting values for Tag_ABI_enum_size between enum_cond.o and
+# linked-in objects.  Work around this by using -nostdlib, making sure there's
+# just one object, and no such conflict can happen.
+lappend opts additional_flags=-nostdlib
+lappend opts additional_flags=-DHAVE_BUILTIN_TRAP=[have_builtin_trap]
+
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $opts] != "" } {
     untested "failed to compile"
     return -1
index 481f9ecdf3d873c046b7ea3f360a11ae0ac02d01..3349da7a263e18d5c556ff13b4c3026e42c2ddcf 100644 (file)
@@ -11072,5 +11072,17 @@ proc section_get {exec section} {
     return $retval
 }
 
+# Return 1 if the compiler supports __builtin_trap, else return 0.
+
+gdb_caching_proc have_builtin_trap {} {
+
+    return [gdb_can_simple_compile builtin_trap {
+       int main() {
+           __builtin_trap ();
+           return 0;
+       }
+    } executable]
+}
+
 # Always load compatibility stuff.
 load_lib future.exp