[ob/pushed] Fix a couple gdb.dwarf2/ testcases with "clang -flto"

Message ID 20200913173703.14759-1-pedro@palves.net
State New
Headers show
Series
  • [ob/pushed] Fix a couple gdb.dwarf2/ testcases with "clang -flto"
Related show

Commit Message

Pedro Alves Sept. 13, 2020, 5:37 p.m.
gdb.dwarf2/atomic-type.exp and gdb.dwarf2/ada-linkage-name.exp fail
when testing with "clang -flto" as compiler, like:

 $ make check TESTS="gdb.dwarf2/ada-linkage-name.exp" RUNTESTFLAGS="CC_FOR_TARGET='clang -flto'"

because with -flto, functions that aren't referenced anywhere are not
emitted in the final binary.  Fix it by adding uses of the functions.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/ada-linkage-name.c (main): Move to the bottom of the
	file and add calls to first and second.
	* gdb.dwarf2/atomic.c (main): Move to the bottom of the file and
	add call to f.
---
 gdb/testsuite/gdb.dwarf2/ada-linkage-name.c | 18 +++++++++++-------
 gdb/testsuite/gdb.dwarf2/atomic.c           | 17 +++++++++--------
 2 files changed, 20 insertions(+), 15 deletions(-)


base-commit: 6791b1172abea5867268c95a460aba1c66c2b6b0
-- 
2.14.5

Patch

diff --git a/gdb/testsuite/gdb.dwarf2/ada-linkage-name.c b/gdb/testsuite/gdb.dwarf2/ada-linkage-name.c
index adcb009cce3..fe0414724e1 100644
--- a/gdb/testsuite/gdb.dwarf2/ada-linkage-name.c
+++ b/gdb/testsuite/gdb.dwarf2/ada-linkage-name.c
@@ -15,13 +15,6 @@ 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-int
-main (void)
-{
-  asm ("main_label: .globl main_label");
-  return 0;
-}
-
 /* First dummy function.  */
 
 int
@@ -39,3 +32,14 @@  second (char *x)
   asm ("second_label: .globl second_label");
   return 0;
 }
+
+
+int
+main (void)
+{
+  asm ("main_label: .globl main_label");
+
+  first (0);
+  second (0);
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.dwarf2/atomic.c b/gdb/testsuite/gdb.dwarf2/atomic.c
index 1e279a40d27..89299890533 100644
--- a/gdb/testsuite/gdb.dwarf2/atomic.c
+++ b/gdb/testsuite/gdb.dwarf2/atomic.c
@@ -15,20 +15,21 @@ 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-/* Dummy main function.  */
-
+/* dummy f function, DWARF will describe arguments and type differently.  */
 int
-main (void)
+f (char *x)
 {
-  asm ("main_label: .globl main_label");
+  asm ("f_label: .globl f_label");
   return 0;
 }
 
-/* dummy f function, DWARF will describe arguments and type differently.  */
+/* Dummy main function.  */
+
 int
-f (char *x)
+main (void)
 {
-  asm ("f_label: .globl f_label");
+  asm ("main_label: .globl main_label");
+
+  f (0);
   return 0;
 }
-