This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: gcc-4.8 + tree-loop-distribute-patterns breaks glibc-2.18
- From: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- To: libc-alpha at sourceware dot org
- Date: Fri, 24 May 2013 15:39:22 -0300
- Subject: Re: gcc-4.8 + tree-loop-distribute-patterns breaks glibc-2.18
- References: <20130520120304 dot GA10899 at winnix> <519A19D4 dot 6000001 at linux dot vnet dot ibm dot com> <519B35C8 dot 108 at suse dot com> <519BC8E3 dot 900 at linux dot vnet dot ibm dot com> <519DAEE3 dot 9050909 at suse dot com> <519DB040 dot 6020201 at suse dot com> <20130523193233 dot 8F5C42C09F at topped-with-meat dot com>
On 05/23/2013 04:32 PM, Roland McGrath wrote:
> I think I described the inadequacy and horridness of this approach already.
> We need a real solution.
>
I do agree with your objections and I believe the following patch is a better
approach. It uses a global definition that sets any memset/memmove symbol generated
by the compiler to internal libc.so one.
Although it fixes the checkplt testcase it does not address possible recursive calls
when building generic string algorithms. I only saw such issue on GCC trunk (so it
might be an compiler issue) and it is related to another issue. I'll bring the issue
if I see it when GCC 4.9 is released.
It fixes the check-localplt issue with GCC 4.8 + O3 I'm seeing on PPC32 and PPC64.
Tested on PPC32, PPC64, and x86_64.
Any comments?
---
2013-05-24 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
* sysdeps/generic/symbol-hacks.h: Add workaround for memset/memmove calls
generated by the compiler on loop optimizations.
* sysdeps/wordsize-32/symbol-hacks.h: Include next symbol-hacks.h for
general definitions.
--
diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h
index bc7b4c4..9eaf014 100644
--- a/sysdeps/generic/symbol-hacks.h
+++ b/sysdeps/generic/symbol-hacks.h
@@ -1 +1,6 @@
-/* Fortunately nothing to do. */
+/* Some compiler optimizations may transform loops into memset/memmove
+ calls and without proper declaration it may generate PLT calls. */
+#if !defined __ASSEMBLER__ && !defined NOT_IN_libc && defined SHARED
+asm ("memmove = __GI_memmove");
+asm ("memset = __GI_memset");
+#endif
diff --git a/sysdeps/wordsize-32/symbol-hacks.h b/sysdeps/wordsize-32/symbol-hacks.h
index 52ac5c1..202a807 100644
--- a/sysdeps/wordsize-32/symbol-hacks.h
+++ b/sysdeps/wordsize-32/symbol-hacks.h
@@ -16,6 +16,8 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include_next "symbol-hacks.h"
+
/* A very dirty trick: gcc emits references to __divdi3, __udivdi3,
__moddi3, and __umoddi3. These functions are exported and
therefore we get PLTs. Unnecessarily so. Changing gcc is a big