[clang] 7370b9c - [Driver] Reject -march= for ppc
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 6 09:17:02 PST 2023
Author: Fangrui Song
Date: 2023-03-06T09:16:57-08:00
New Revision: 7370b9c8ea0049f103daae0126861ba4f6ff6f4a
URL: https://github.com/llvm/llvm-project/commit/7370b9c8ea0049f103daae0126861ba4f6ff6f4a
DIFF: https://github.com/llvm/llvm-project/commit/7370b9c8ea0049f103daae0126861ba4f6ff6f4a.diff
LOG: [Driver] Reject -march= for ppc
Clang -march= for ppc triples currently leads to an
-Wunused-command-line-argument warning but GCC rejects -march=.
error: unrecognized command-line option ‘-march=xxx’
Let's reject -march= as well similar to the Sparc change D130273.
Close https://github.com/llvm/llvm-project/issues/57587
Reviewed By: #powerpc, nemanjai
Differential Revision: https://reviews.llvm.org/D145141
Added:
Modified:
clang/lib/Driver/ToolChains/Arch/PPC.cpp
clang/lib/Driver/ToolChains/Arch/PPC.h
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/ppc-cpus.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Arch/PPC.cpp b/clang/lib/Driver/ToolChains/Arch/PPC.cpp
index 8824253cc9846..4287d41534693 100644
--- a/clang/lib/Driver/ToolChains/Arch/PPC.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -85,7 +85,12 @@ std::string ppc::getPPCTuneCPU(const ArgList &Args, const llvm::Triple &T) {
}
/// Get the (LLVM) name of the PowerPC cpu we are targeting.
-std::string ppc::getPPCTargetCPU(const ArgList &Args, const llvm::Triple &T) {
+std::string ppc::getPPCTargetCPU(const Driver &D, const ArgList &Args,
+ const llvm::Triple &T) {
+ if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
+ D.Diag(diag::err_drv_unsupported_opt_for_target)
+ << A->getSpelling() << T.getTriple();
+ }
if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ))
return normalizeCPUName(A->getValue(), T);
return getPPCGenericTargetCPU(T);
diff --git a/clang/lib/Driver/ToolChains/Arch/PPC.h b/clang/lib/Driver/ToolChains/Arch/PPC.h
index 97ac450838521..ec5b3c8140b66 100644
--- a/clang/lib/Driver/ToolChains/Arch/PPC.h
+++ b/clang/lib/Driver/ToolChains/Arch/PPC.h
@@ -35,7 +35,7 @@ enum class ReadGOTPtrMode {
FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
-std::string getPPCTargetCPU(const llvm::opt::ArgList &Args,
+std::string getPPCTargetCPU(const Driver &D, const llvm::opt::ArgList &Args,
const llvm::Triple &T);
std::string getPPCTuneCPU(const llvm::opt::ArgList &Args,
const llvm::Triple &T);
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index c179c4152cee4..dc46b625bb676 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -410,7 +410,7 @@ std::string tools::getCPUName(const Driver &D, const ArgList &Args,
case llvm::Triple::ppcle:
case llvm::Triple::ppc64:
case llvm::Triple::ppc64le:
- return ppc::getPPCTargetCPU(Args, T);
+ return ppc::getPPCTargetCPU(D, Args, T);
case llvm::Triple::csky:
if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
diff --git a/clang/test/Driver/ppc-cpus.c b/clang/test/Driver/ppc-cpus.c
index 050512f9d87be..4edd83b4d6d28 100644
--- a/clang/test/Driver/ppc-cpus.c
+++ b/clang/test/Driver/ppc-cpus.c
@@ -39,3 +39,6 @@
// RUN: %clang -### -c -target powerpc64 %s -mcpu=405 2>&1 | FileCheck %s --check-prefix=GENERIC
//
// GENERIC: "-target-cpu" "ppc64"
+
+// RUN: %clang -### -c --target=powerpc64 %s -march=generic 2>&1 | FileCheck --check-prefix=MARCH %s
+// MARCH: error: unsupported option '-march=' for target 'powerpc64'
More information about the cfe-commits
mailing list