summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/ToolChain.cpp
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2012-03-21 16:31:37 +0000
committerBob Wilson <bob.wilson@apple.com>2012-03-21 16:31:37 +0000
commitcc4ab9d9c0095dc6841e36e79270eaf81177fc50 (patch)
tree4947da002a1ce208f0f653cd6610dfc6f1e4b1e8 /clang/lib/Driver/ToolChain.cpp
parenteb4eb5cad9a31450fc0ecb560fb88f90a22c92f3 (diff)
downloadbcm5719-llvm-cc4ab9d9c0095dc6841e36e79270eaf81177fc50.tar.gz
bcm5719-llvm-cc4ab9d9c0095dc6841e36e79270eaf81177fc50.zip
For Darwin, do not let -mcpu override the -arch option. <rdar://11059238>
On Darwin the architecture and the corresponding Mach-O slice is typically specified with -arch. If not, it defaults to the current host architecture. Do not use -mcpu to override the -arch value. This is only an issue when people need to use specialized code for a non-default CPU (hopefully guarded by run-time checks to detect the current processor). The -mcpu option is still used for the -target-cpu option to clang, but this patch causes it to not be used to set the architecture in the target triple. llvm-svn: 153197
Diffstat (limited to 'clang/lib/Driver/ToolChain.cpp')
-rw-r--r--clang/lib/Driver/ToolChain.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index b4f5d0b4210..eea460bd33e 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -74,11 +74,15 @@ void ToolChain::configureObjCRuntime(ObjCRuntime &runtime) const {
// FIXME: tblgen this.
static const char *getARMTargetCPU(const ArgList &Args,
const llvm::Triple &Triple) {
- // FIXME: Warn on inconsistent use of -mcpu and -march.
-
- // If we have -mcpu=, use that.
- if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
- return A->getValue(Args);
+ // For Darwin targets, the -arch option (which is translated to a
+ // corresponding -march option) should determine the architecture
+ // (and the Mach-O slice) regardless of any -mcpu options.
+ if (!Triple.isOSDarwin()) {
+ // FIXME: Warn on inconsistent use of -mcpu and -march.
+ // If we have -mcpu=, use that.
+ if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
+ return A->getValue(Args);
+ }
StringRef MArch;
if (Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
OpenPOWER on IntegriCloud