From 8c143331b0216809343d056b084e29a0ab3311a7 Mon Sep 17 00:00:00 2001
From: barracuda156 <vital.had@gmail.com>
Date: Fri, 15 Dec 2023 22:55:52 +0800
Subject: [PATCH] PPC970: drop -mcpu=970 which seems to produce faulty code

Fixes: https://github.com/OpenMathLib/OpenBLAS/issues/4376
---
 cmake/cc.cmake | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git cmake/cc.cmake cmake/cc.cmake
index d5bf3b7ee..00952e810 100644
--- cmake/cc.cmake
+++ cmake/cc.cmake
@@ -282,18 +282,21 @@ if (${CORE} STREQUAL POWER8)
   endif ()
 endif ()
 
+# With -mcpu=970 added it compiles, but library is broken, at least on macOS. If someone
+# tests on *BSD or Linux and adds this flag, please make sure it is not used for macOS case.
 if (${CORE} STREQUAL PPC970)
   if (NOT DYNAMIC_ARCH)
-    set (CCOMMON_OPT  "${CCOMMON_OPT} -mcpu=970 -mtune=970 -maltivec -fno-fast-math")
+    set (CCOMMON_OPT  "${CCOMMON_OPT} -mtune=970 -maltivec -fno-fast-math")
   endif ()
   if (APPLE)
     set (CCOMMON_OPT  "${CCOMMON_OPT} -force_cpusubtype_ALL")
   endif ()
 endif ()
 
+# -mcpu=G4 seems to work fine, but perhaps avoid it for the sake of consistency?
 if (${CORE} STREQUAL PPCG4)
   if (NOT DYNAMIC_ARCH)
-    set (CCOMMON_OPT  "${CCOMMON_OPT} -mcpu=G4 -mtune=G4 -maltivec -fno-fast-math")
+    set (CCOMMON_OPT  "${CCOMMON_OPT} -mtune=G4 -maltivec -fno-fast-math")
   endif ()
   if (APPLE)
     set (CCOMMON_OPT  "${CCOMMON_OPT} -force_cpusubtype_ALL")
