[PATCH] Call powerpc-darwin external tools with -arch ppc

Stephen Drake steve at synergyconsultingnz.com
Wed Jul 16 01:29:58 PDT 2014


Hi,

I'm attaching a patch to call external tools for powerpc-darwin with "-arch ppc" instead of "-arch powerpc", so as to be compatible with the cctools assembler and ld64 linker.

This bug report describing the case has been closed, but I see the same behaviour now:
http://llvm.org/bugs/show_bug.cgi?id=3830

The bug report also contains a patch, which along with similar code further up at lib/Driver/Tools.cpp:4721, forms the basis for this patch.  The existing code is marked "FIXME", which I have carried over - if someone can explain the problem and/or suggest a better way to implement this I'll be happy to give it a shot.  Perhaps ToolChain::getDefaultUniversalArchName() is the correct way to find the arch name here?

Cheers,
Steve


Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp	(revision 213105)
+++ lib/Driver/Tools.cpp	(working copy)
@@ -5313,12 +5313,22 @@
 
 void darwin::MachOTool::AddMachOArch(const ArgList &Args,
                                      ArgStringList &CmdArgs) const {
+  llvm::Triple::ArchType Arch = getToolChain().getArch();
   StringRef ArchName = getMachOToolChain().getMachOArchName(Args);
 
   // Derived from darwin_arch spec.
   CmdArgs.push_back("-arch");
-  CmdArgs.push_back(Args.MakeArgString(ArchName));
 
+  // FIXME: Remove these special cases.
+  if (Arch == llvm::Triple::ppc)
+    CmdArgs.push_back("ppc");
+  else if (Arch == llvm::Triple::ppc64)
+    CmdArgs.push_back("ppc64");
+  else if (Arch == llvm::Triple::ppc64le)
+    CmdArgs.push_back("ppc64le");
+  else
+    CmdArgs.push_back(Args.MakeArgString(ArchName));
+
   // FIXME: Is this needed anymore?
   if (ArchName == "arm")
     CmdArgs.push_back("-force_cpusubtype_ALL");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: lib-Driver-Tools.cpp.patch
Type: application/octet-stream
Size: 1019 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140716/b3756d64/attachment.obj>


More information about the cfe-commits mailing list