This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[testcase] Simplified testcases why current gcc trunk cannot compile glibc


Hi!

Below are 2 tests, the first one passes with current gcc trunk, the second
one does not (it simply decides not to emit foo at all).
I'd like to know if you think it is a bug in gcc or not.
It looks like older gcc versions work similarly, the only difference between
current trunk and older GCCs is that gcc does this now for even fairly big
foo (in glibc particularly _dl_start, fixup and profile_fixup, actually,
those routines are not very big, but inline tons of other routines).
E.g. _dl_start is usually recerenced from RTLD_START assembly, which is just
asm ("..."); found outside any function (thus the trick with "i" cannot be
used).
I've tried ugly workaround (adding
  asm ("# %0" : : "m" (_dl_start));
to some other function and hoping gcc doesn't get some day clever even more
to blow everything away from rtld.c (since basically all the rest is
referenced from _dl_start (usually indirectly through other functions)))
which seems to work, but I wonder if gcc shouldn't stay at possible warning
(unless unused attribute was present and emit things anyway).

2001-10-15  Jakub Jelinek  <jakub@redhat.com>

	* gcc.dg/20011015-1.c: New test.
	* gcc.dg/20011015-2.c: New test.

--- gcc/testsuite/gcc.dg/20011015-1.c.jj	Mon Oct 15 14:49:26 2001
+++ gcc/testsuite/gcc.dg/20011015-1.c	Mon Oct 15 14:35:35 2001
@@ -0,0 +1,22 @@
+/* { dg-do run { target i?86-*-linux* } } */
+/* { dg-options "-O3" } */
+
+extern void abort (void);
+extern void exit (int);
+
+static int
+foo (void)
+{
+  return 31;
+}
+
+int
+main(void)
+{
+  int (*fn) (void);
+
+  asm ("movl %1, %0" : "=r" (fn) : "i" (foo));
+  if (fn () != 31)
+    abort ();
+  exit (0);
+}
--- gcc/testsuite/gcc.dg/20011015-2.c.jj	Mon Oct 15 14:49:28 2001
+++ gcc/testsuite/gcc.dg/20011015-2.c	Mon Oct 15 14:36:46 2001
@@ -0,0 +1,23 @@
+/* { dg-do run { target i?86-*-linux* } } */
+/* { dg-options "-O3" } */
+
+extern void abort (void);
+extern void exit (int);
+
+static int
+__attribute__ ((unused))
+foo (void)
+{
+  return 31;
+}
+
+int
+main(void)
+{
+  int (*fn) (void);
+
+  asm ("movl foo, %0" : "=r" (fn));
+  if (fn () != 31)
+    abort ();
+  exit (0);
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]