From: Rafael Espindola Date: Thu, 28 Aug 2014 21:23:05 +0000 (+0000) Subject: Call powerpc-darwin external tools with -arch ppc. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=52fc295aad114ea91f4118d5e48fdfa142871704;p=clang Call powerpc-darwin external tools with -arch ppc. With this patch we 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. Patch by Stephen Drake! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216687 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 2f4711563c..f18b6feb68 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -156,7 +156,7 @@ static bool isSoftFloatABI(const ArgList &Args) { StringRef MachO::getMachOArchName(const ArgList &Args) const { switch (getTriple().getArch()) { default: - return getArchName(); + return getDefaultUniversalArchName(); case llvm::Triple::aarch64: return "arm64"; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index de64d934f9..d751ca9a11 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -4952,19 +4952,10 @@ void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA, RenderExtraToolArgs(JA, CmdArgs); // If using a driver driver, force the arch. - llvm::Triple::ArchType Arch = getToolChain().getArch(); if (getToolChain().getTriple().isOSDarwin()) { CmdArgs.push_back("-arch"); - - // 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(getToolChain().getArchName())); + CmdArgs.push_back( + Args.MakeArgString(getToolChain().getDefaultUniversalArchName())); } // Try to force gcc to match the tool chain we want, if we recognize @@ -4972,6 +4963,7 @@ void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA, // // FIXME: The triple class should directly provide the information we want // here. + llvm::Triple::ArchType Arch = getToolChain().getArch(); if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::ppc) CmdArgs.push_back("-m32"); else if (Arch == llvm::Triple::x86_64 || Arch == llvm::Triple::ppc64 || diff --git a/test/Driver/darwin-arch-default.c b/test/Driver/darwin-arch-default.c index 60bf61de8a..e7e5e89ed0 100644 --- a/test/Driver/darwin-arch-default.c +++ b/test/Driver/darwin-arch-default.c @@ -2,6 +2,42 @@ // // RUN: %clang -target powerpc-apple-darwin8 -### \ // RUN: -ccc-print-phases %s 2> %t -// RUN: FileCheck --check-prefix=CHECK-POWERPC < %t %s +// RUN: FileCheck --check-prefix=CHECK-BIND-PPC < %t %s // -// CHECK-POWERPC: bind-arch, "ppc" +// CHECK-BIND-PPC: bind-arch, "ppc" +// +// RUN: %clang -target powerpc64-apple-darwin8 -### \ +// RUN: -ccc-print-phases %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-BIND-PPC64 < %t %s +// +// CHECK-BIND-PPC64: bind-arch, "ppc64" + +// Check that the correct arch name is passed to the external assembler +// +// RUN: %clang -target powerpc-apple-darwin8 -### \ +// RUN: -no-integrated-as -c %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-AS-PPC < %t %s +// +// CHECK-AS-PPC: {{as(.exe)?"}} +// CHECK-AS-PPC: "-arch" "ppc" +// +// RUN: %clang -target powerpc64-apple-darwin8 -### \ +// RUN: -no-integrated-as -c %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-AS-PPC64 < %t %s +// +// CHECK-AS-PPC64: {{as(.exe)?"}} +// CHECK-AS-PPC64: "-arch" "ppc64" + +// Check that the correct arch name is passed to the external linker +// +// RUN: %clang -target powerpc-apple-darwin8 -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-LD-PPC < %t %s +// +// CHECK-LD-PPC: {{ld(.exe)?"}} +// CHECK-LD-PPC: "-arch" "ppc" +// +// RUN: %clang -target powerpc64-apple-darwin8 -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-LD-PPC64 < %t %s +// +// CHECK-LD-PPC64: {{ld(.exe)?"}} +// CHECK-LD-PPC64: "-arch" "ppc64"