This is the mail archive of the libc-alpha@sourceware.org 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]
Other format: [Raw text]

[POWERPC] Don't override gcc -mcpu with wrong asm .machine


If powerpc gcc is modified to not pass -many to the assembler, glibc
builds break.  -many is a sticky option, which means .machine in the
source isn't really effective in selecting an instruction set.  You do
get the insns you want, in particular with the operand variations for
the given cpu, but then all other cpu instructions are made available
too.  So, ".machine power4" in power4/memcmp.S doesn't stop you using
power7 insns as used by the little-endian code in that file.  However
if -many is not in force, power4/memcmp.S won't compile for
powerpc64le.

It's rather strange that these files use .machine at all.  Perhaps
that was a workaround for versions of gcc that didn't pass -m<cpu> (or
passed a wrong -m<cpu>) to the assembler unless -mcpu was given?  Even
with such a gcc, I believe you'll get the correct -m<cpu> if the glibc
makefiles always pass -mcpu=<cpu> to gcc.  Since I haven't verified
that all possible powerpc build variants do that, I haven't completely
removed .machine, but instead put the .machine directive inside an
ifdef test of a macro defined by gcc.  Now if the Makefile passes
-mcpu=power8 the assembly won't disagree by using ".machine power7".

	* sysdeps/powerpc/powerpc64/power4/memcmp.S: Don't emit .machine
	when __LITTLE_ENDIAN__.
	* sysdeps/powerpc/powerpc64/power8/strcasecmp.S: Don't emit .machine
	when _ARCH_PWR8.
	* sysdeps/powerpc/powerpc64/power8/strcasestr.S: Likewise.

diff --git a/sysdeps/powerpc/powerpc64/power4/memcmp.S b/sysdeps/powerpc/powerpc64/power4/memcmp.S
index c366801..6cb4a16 100644
--- a/sysdeps/powerpc/powerpc64/power4/memcmp.S
+++ b/sysdeps/powerpc/powerpc64/power4/memcmp.S
@@ -26,7 +26,9 @@
 # define MEMCMP memcmp
 #endif
 
+#ifndef __LITTLE_ENDIAN__
 	.machine power4
+#endif
 ENTRY_TOCLESS (MEMCMP, 4)
 	CALL_MCOUNT 3
 
diff --git a/sysdeps/powerpc/powerpc64/power8/strcasecmp.S b/sysdeps/powerpc/powerpc64/power8/strcasecmp.S
index 88b17a6..0655bd7 100644
--- a/sysdeps/powerpc/powerpc64/power8/strcasecmp.S
+++ b/sysdeps/powerpc/powerpc64/power8/strcasecmp.S
@@ -98,6 +98,7 @@
 #  define VPOPCNTD_V8_V8	vpopcntd v8, v8;
 #  define VADDUQM_V7_V8	vadduqm	v9, v7, v8;
 #else
+	.machine  power7
 #  define VCLZD_V8_v7	.long	0x11003fc2
 #  define MFVRD_R3_V1	.long	0x7c230067
 #  define VSUBUDM_V9_V8	.long	0x112944c0
@@ -105,8 +106,6 @@
 #  define VADDUQM_V7_V8	.long	0x11274100
 #endif
 
-	.machine  power7
-
 ENTRY (__STRCASECMP)
 #ifdef USE_AS_STRNCASECMP
 	CALL_MCOUNT 3
diff --git a/sysdeps/powerpc/powerpc64/power8/strcasestr.S b/sysdeps/powerpc/powerpc64/power8/strcasestr.S
index 3f59cb0..c301387 100644
--- a/sysdeps/powerpc/powerpc64/power8/strcasestr.S
+++ b/sysdeps/powerpc/powerpc64/power8/strcasestr.S
@@ -78,13 +78,11 @@
 #ifdef _ARCH_PWR8
 #define VCLZD_V8_v7	vclzd	v8, v7;
 #else
+	.machine  power7
 #define VCLZD_V8_v7	.long	0x11003fc2
 #endif
 
 #define	FRAMESIZE	(FRAME_MIN_SIZE+48)
-/* TODO: change this to .machine power8 when the minimum required binutils
-   allows it.  */
-	.machine  power7
 ENTRY (STRCASESTR, 4)
 	CALL_MCOUNT 2
 	mflr	r0			/* Load link register LR to r0.  */

-- 
Alan Modra
Australia Development Lab, IBM


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