From 93300e85de8ff472bd8bfba2850ad9111eb0c080 Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Date: Sat, 17 Jan 2015 09:03:43 -0800
Subject: [PATCH 4/7] Set the Mach-O CPU Subtype to ppc7400 when targeting
 Leopard

http://llvm.org/bugs/show_bug.cgi?id=18463

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
(cherry picked from commit 53f17b9930d8ace72f8a8f241bc54ce65e29ecd0)

Conflicts:
	lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
---
 lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git llvm_release_34/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp macports_release_34/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
index 0d42081..7260c10 100644
--- llvm_release_34/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
+++ macports_release_34/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
@@ -159,16 +159,23 @@ public:
 // FIXME: This should be in a separate file.
 namespace {
   class DarwinPPCAsmBackend : public PPCAsmBackend {
+    Triple TheTriple;
   public:
-    DarwinPPCAsmBackend(const Target &T) : PPCAsmBackend(T) { }
+    DarwinPPCAsmBackend(const Target &T, StringRef TT) : PPCAsmBackend(T), TheTriple(TT) { }
 
     MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
       bool is64 = getPointerSize() == 8;
+      MachO::CPUSubTypePowerPC CS = MachO::CPU_SUBTYPE_POWERPC_ALL;
+
+      if (TheTriple.isOSDarwin() && !TheTriple.isMacOSXVersionLT(10,5)) {
+          CS = MachO::CPU_SUBTYPE_POWERPC_7400;
+      }
+
       return createPPCMachObjectWriter(
           OS,
           /*Is64Bit=*/is64,
           (is64 ? MachO::CPU_TYPE_POWERPC64 : MachO::CPU_TYPE_POWERPC),
-          MachO::CPU_SUBTYPE_POWERPC_ALL);
+          CS);
     }
 
     virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
@@ -198,8 +205,9 @@ namespace {
 MCAsmBackend *llvm::createPPCAsmBackend(const Target &T,
                                         const MCRegisterInfo &MRI,
                                         StringRef TT, StringRef CPU) {
+
   if (Triple(TT).isOSDarwin())
-    return new DarwinPPCAsmBackend(T);
+    return new DarwinPPCAsmBackend(T, TT);
 
   uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(Triple(TT).getOS());
   return new ELFPPCAsmBackend(T, OSABI);
-- 
2.2.2

