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