I'm assuming that you mean a cross-compile (which is a stage1 without -werror).
If you look in the build output (I just repeated this on x86_64-darwin12 X
powerpc-darwin9) you'll see:
/GCC/gcc-trunk/gcc/config/rs6000/rs6000.c:24404:1: warning: ‘bool
rs6000_keep_leaf_when_profiled()’ defined but not used [-Wunused-function]
rs6000_keep_leaf_when_profiled (void)
^
this becomes a bootstrap error at stage#2. If you don't see that, then I have
don't have the same patch applied as you :).
Yes, I meant a cross-compile. I don't have a Darwin environment
but I managed to reproduce it while building stage1 with -Werror
(after fixing a number of problems that cause the build to fail
earlier on). Thanks for your patience.
Attached is an updated patch with your suggested change (i.e.,
defining the TARGET_KEEP_LEAF_WHEN_PROFILED macro in rs6000.h
instead of linux64.h).
I tested the patch by building stage1 with -Werror for both
powerpc64-darwin9 and powerpc64-unknown-linux-gnu (both on
the latter target).
Martin
2015-03-24 Anton Blanchard <an...@samba.org>
PR target/63354
* config/rs6000/rs6000.h (TARGET_KEEP_LEAF_WHEN_PROFILED): Define.
* config/rs6000/rs6000.c (rs6000_keep_leaf_when_profiled): New
function.
2015-03-24 Martin Sebor <mse...@redhat.com>
PR target/63354
* gcc.target/powerpc/pr63354.c: New test.
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 31b46ea..f1508b9 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -24397,6 +24397,23 @@ rs6000_output_function_prologue (FILE *file,
rs6000_pic_labelno++;
}
+/* -mprofile-kernel code calls mcount before the function prologue,
+ so a profiled leaf function should stay a leaf function. */
+
+static bool
+rs6000_keep_leaf_when_profiled (void)
+{
+ switch (DEFAULT_ABI)
+ {
+ case ABI_AIX:
+ case ABI_ELFv2:
+ return TARGET_PROFILE_KERNEL;
+
+ default:
+ return true;
+ }
+}
+
/* Non-zero if vmx regs are restored before the frame pop, zero if
we restore after the pop when possible. */
#define ALWAYS_RESTORE_ALTIVEC_BEFORE_POP 0
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index ef6bb2f..50394b0 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -703,6 +703,9 @@ extern unsigned char rs6000_recip_bits[];
#define TARGET_CPU_CPP_BUILTINS() \
rs6000_cpu_cpp_builtins (pfile)
+#undef TARGET_KEEP_LEAF_WHEN_PROFILED
+#define TARGET_KEEP_LEAF_WHEN_PROFILED rs6000_keep_leaf_when_profiled
+
/* This is used by rs6000_cpu_cpp_builtins to indicate the byte order
we're compiling for. Some configurations may need to override it. */
#define RS6000_CPU_CPP_ENDIAN_BUILTINS() \
diff --git a/gcc/testsuite/gcc.target/powerpc/pr63354.c b/gcc/testsuite/gcc.target/powerpc/pr63354.c
new file mode 100644
index 0000000..9e635cc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr63354.c
@@ -0,0 +1,10 @@
+/* { dg-do compile { target { powerpc64*-*-linux* } } } */
+/* { dg-options "-O2 -pg -mprofile-kernel" } */
+
+int foo (void)
+{
+ return 1;
+}
+
+/* { dg-final { scan-assembler "bl _mcount" } } */
+/* { dg-final { scan-assembler-not "(addi|stdu) 1," } } */