PATCH: Fix 64-bit profiling on Solaris 10+/x86 (PR target/38085)
Rainer Orth
ro@CeBiTec.Uni-Bielefeld.DE
Mon Mar 15 18:50:00 GMT 2010
As reported in the PR, 64-bit profiling on Solaris 10+/x86 doesn't work
for a couple of reasons:
* The code emitted contains a typo.
* The copy of gmon.o in the amd64 subdir is a 32-bit object instead.
* Sun as chokes on the callq in gmon-sol2.c.
The following patch fixes this and allows the affected testcases to
succeed. Apart from fixing the typo, I've found that the rule for
gmon.o in libgcc/config/i386/t-sol2 still used $(MULTILIB_CFLAGS), which
isn't set inside libgcc at all. Using $(CFLAGS) instead fixes the
problem. The callq is unnecessary: call works just as well, created
identical code and is understood by Sun as and gas.
In the PR, one submitter mentioned crashes of the programs compiled with
-pg even after fixing the typo. I couldn't reproduce this at all: a
simple test programs (just main calling the same function 100 times)
works fine, and both gcc -pg and cc -xpg produce the same gmon.out
(modulo the exact runtimes).
Ok for mainline and the 4.4 branch?
Raine
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
2010-02-12 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
gcc:
PR target/38085
* config/i386/i386.c (x86_function_profiler)
[!NO_PROFILE_COUNTERS]: Fix typo.
* config/i386/gmon-sol2.c (_mcleanup) [__x86_64__]: Use call
instead of callq.
libgcc:
PR target/38085
* config/i386/t-sol2 ($(T)gmon.o): Use CFLAGS instead of
MULTILIB_CFLAGS.
($(T)gcrt1.o): Likewise.
($(T)crt1.o): Likewise.
($(T)crti.o): Likewise.
($(T)crtn.o): Likewise.
diff -r 6ac73028b672 -r 8a1775a9ba2a gcc/config/i386/i386.c
--- a/gcc/config/i386/i386.c Thu Feb 11 23:20:25 2010 +0100
+++ b/gcc/config/i386/i386.c Fri Feb 12 01:39:12 2010 +0100
@@ -26245,7 +26245,7 @@
if (TARGET_64BIT)
{
#ifndef NO_PROFILE_COUNTERS
- fprintf (file, "\tleaq\t" LPREFIX "P%d@(%%rip),%%r11\n", labelno);
+ fprintf (file, "\tleaq\t" LPREFIX "P%d(%%rip),%%r11\n", labelno);
#endif
if (DEFAULT_ABI == SYSV_ABI && flag_pic)
diff -r 6ac73028b672 -r 8a1775a9ba2a libgcc/config/i386/t-sol2
--- a/libgcc/config/i386/t-sol2 Thu Feb 11 23:20:25 2010 +0100
+++ b/libgcc/config/i386/t-sol2 Fri Feb 12 01:39:12 2010 +0100
@@ -1,6 +1,6 @@
# gmon build rule:
$(T)gmon.o: $(gcc_srcdir)/config/i386/gmon-sol2.c $(GCC_PASSES) $(CONFIG_H)
- $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) \
+ $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(CFLAGS) \
-c $(gcc_srcdir)/config/i386/gmon-sol2.c -o $(T)gmon.o
# Assemble startup files.
@@ -9,16 +9,16 @@
# the comments with sed. This bug may only be in the Early Access releases.
$(T)gcrt1.o: $(gcc_srcdir)/config/i386/sol2-gc1.asm $(GCC_PASSES)
sed -e '/^!/d' <$(gcc_srcdir)/config/i386/sol2-gc1.asm >gcrt1.s
- $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)gcrt1.o gcrt1.s
+ $(GCC_FOR_TARGET) $(CFLAGS) -c -o $(T)gcrt1.o gcrt1.s
$(T)crt1.o: $(gcc_srcdir)/config/i386/sol2-c1.asm $(GCC_PASSES)
sed -e '/^!/d' <$(gcc_srcdir)/config/i386/sol2-c1.asm >crt1.s
- $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crt1.o crt1.s
+ $(GCC_FOR_TARGET) $(CFLAGS) -c -o $(T)crt1.o crt1.s
$(T)crti.o: $(gcc_srcdir)/config/i386/sol2-ci.asm $(GCC_PASSES)
sed -e '/^!/d' <$(gcc_srcdir)/config/i386/sol2-ci.asm >crti.s
- $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crti.o crti.s
+ $(GCC_FOR_TARGET) $(CFLAGS) -c -o $(T)crti.o crti.s
$(T)crtn.o: $(gcc_srcdir)/config/i386/sol2-cn.asm $(GCC_PASSES)
sed -e '/^!/d' <$(gcc_srcdir)/config/i386/sol2-cn.asm >crtn.s
- $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crtn.o crtn.s
+ $(GCC_FOR_TARGET) $(CFLAGS) -c -o $(T)crtn.o crtn.s
# We need to use -fPIC when we are using gcc to compile the routines in
# crtstuff.c. This is only really needed when we are going to use gcc/g++
More information about the Gcc-patches
mailing list