94084c
commit 82b1acd9de9796298a230d7484f26fe9a7756d18
94084c
Author: Paul A. Clarke <pc@us.ibm.com>
94084c
Date:   Sat Sep 25 09:57:15 2021 -0500
94084c
94084c
    powerpc: Fix unrecognized instruction errors with recent binutils
94084c
    
94084c
    Recent versions of binutils (with commit
94084c
    b25f942e18d6ecd7ec3e2d2e9930eb4f996c258a) stopped preserving "sticky"
94084c
    options across a base `.machine` directive, nullifying the use of
94084c
    passing "-many" through GCC to the assembler.  As a result, some
94084c
    instructions which were recognized even under older, more stringent
94084c
    `.machine` directives become unrecognized instructions in that
94084c
    context.
94084c
    
94084c
    In `sysdeps/powerpc/tst-set_ppr.c`, the use of the `mfppr32` extended
94084c
    mnemonic became unrecognized, as the default compilation with GCC for
94084c
    32bit powerpc adds a `.machine ppc` in the resulting assembly, so the
94084c
    command line option `-Wa,-many` is essentially ignored, and the ISA 2.06
94084c
    instructions and mnemonics, like `mfppr32`, are unrecognized.
94084c
    
94084c
    The compilation of `sysdeps/powerpc/tst-set_ppr.c` fails with:
94084c
    Error: unrecognized opcode: `mfppr32'
94084c
    
94084c
    Add appropriate `.machine` directives in the assembly to bracket the
94084c
    `mfppr32` instruction.
94084c
    
94084c
    Part of a 2019 fix (commit 9250e6610fdb0f3a6f238d2813e319a41fb7a810) to
94084c
    the above test's Makefile to add `-many` to the compilation when GCC
94084c
    itself stopped passing `-many` to the assember no longer has any effect,
94084c
    so remove that.
94084c
    
94084c
    Reported-by: Joseph Myers <joseph@codesourcery.com>
94084c
    (cherry picked from commit ee874f44fd55988808a4a162ef21bfa2cc8dc6f7)
94084c
94084c
diff --git a/sysdeps/powerpc/Makefile b/sysdeps/powerpc/Makefile
94084c
index 09860ffc0155d765..5e6cb07ce66decfa 100644
94084c
--- a/sysdeps/powerpc/Makefile
94084c
+++ b/sysdeps/powerpc/Makefile
94084c
@@ -61,11 +61,6 @@ ifeq ($(subdir),misc)
94084c
 sysdep_headers += sys/platform/ppc.h
94084c
 tests += test-gettimebase
94084c
 tests += tst-set_ppr
94084c
-
94084c
-# This test is expected to run and exit with EXIT_UNSUPPORTED on
94084c
-# processors that do not implement the Power ISA 2.06 or greater.
94084c
-# But the test makes use of instructions from Power ISA 2.06 and 2.07.
94084c
-CFLAGS-tst-set_ppr.c += -Wa,-many
94084c
 endif
94084c
 
94084c
 ifeq ($(subdir),wcsmbs)
94084c
diff --git a/sysdeps/powerpc/tst-set_ppr.c b/sysdeps/powerpc/tst-set_ppr.c
94084c
index 7684f5d6ea905c60..e80da15320635585 100644
94084c
--- a/sysdeps/powerpc/tst-set_ppr.c
94084c
+++ b/sysdeps/powerpc/tst-set_ppr.c
94084c
@@ -44,7 +44,8 @@ get_thread_priority (void)
94084c
 {
94084c
   /* Read the PPR.  */
94084c
   ppr_t ppr;
94084c
-  asm volatile (MFPPR" %0" : "=r"(ppr));
94084c
+  asm volatile (".machine push; .machine power7; "MFPPR" %0; .machine pop"
94084c
+		: "=r"(ppr));
94084c
   /* Return the thread priority value.  */
94084c
   return EXTRACT_THREAD_PRIORITY (ppr);
94084c
 }