From 2a45fa7cf67bf88a4edf56d637f6ec7326e44ef8 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 21 Jun 2011 00:20:17 +0000 Subject: [PATCH] Driver/Darwin: Honor -Xarch_FOO when the arch matches either the toolchain or the architecture being bound. - Fixes things like -Xarch_armv7. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133490 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains.cpp | 7 ++++++- test/Driver/darwin-xarch.c | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 53ef72295d..e9bea426ae 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -682,8 +682,13 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args, Arg *A = *it; if (A->getOption().matches(options::OPT_Xarch__)) { + // Skip this argument unless the architecture matches either the toolchain + // triple arch, or the arch being bound. + // // FIXME: Canonicalize name. - if (getArchName() != A->getValue(Args, 0)) + llvm::StringRef XarchArch = A->getValue(Args, 0); + if (!(XarchArch == getArchName() || + (BoundArch && XarchArch == BoundArch))) continue; Arg *OriginalArg = A; diff --git a/test/Driver/darwin-xarch.c b/test/Driver/darwin-xarch.c index d16d5318f7..4c6689cef0 100644 --- a/test/Driver/darwin-xarch.c +++ b/test/Driver/darwin-xarch.c @@ -12,3 +12,9 @@ // RUN: FileCheck --check-prefix=CHECK-LINK < %t %s // // CHECK-LINK: ld{{.*}} "-arch" "i386"{{.*}} "-some-linker-arg" + +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### \ +// RUN: -arch armv7 -Xarch_armv7 -Wl,-some-linker-arg -filelist X 2> %t +// RUN: FileCheck --check-prefix=CHECK-ARMV7-LINK < %t %s +// +// CHECK-ARMV7-LINK: ld{{.*}} "-arch" "armv7"{{.*}} "-some-linker-arg"