From f8cf1611e33009029956ff76318f1176825e5bf5 Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Fri, 21 Feb 2014 00:20:07 +0000 Subject: [PATCH] Fix an assertion failure when invoking dsymutil. There is no bound architecture for the dsymutil action in the driver. Trying to check various properties of the target will cause an assertion failure because the target doesn't get initialized without a bound architecture. llvm-svn: 201830 --- clang/lib/Driver/ToolChains.cpp | 7 +++++-- clang/test/Driver/darwin-dsymutil.c | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp index c071a9833cf1..4d29a51f4f8b 100644 --- a/clang/lib/Driver/ToolChains.cpp +++ b/clang/lib/Driver/ToolChains.cpp @@ -893,11 +893,14 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args, DerivedArgList *DAL = MachO::TranslateArgs(Args, BoundArch); const OptTable &Opts = getDriver().getOpts(); + // If no architecture is bound, none of the translations here are relevant. + if (!BoundArch) + return DAL; + // Add an explicit version min argument for the deployment target. We do this // after argument translation because -Xarch_ arguments may add a version min // argument. - if (BoundArch) - AddDeploymentTarget(*DAL); + AddDeploymentTarget(*DAL); // For iOS 6, undo the translation to add -static for -mkernel/-fapple-kext. // FIXME: It would be far better to avoid inserting those -static arguments, diff --git a/clang/test/Driver/darwin-dsymutil.c b/clang/test/Driver/darwin-dsymutil.c index b8c3083c9353..59084a2c85ed 100644 --- a/clang/test/Driver/darwin-dsymutil.c +++ b/clang/test/Driver/darwin-dsymutil.c @@ -43,3 +43,6 @@ // RUN: FileCheck -check-prefix=CHECK-LOCATION < %t %s // CHECK-LOCATION: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["bar/foo"], output: "bar/foo.dSYM" + +// Check that we don't crash when translating arguments for dsymutil. +// RUN: %clang -m32 -arch x86_64 -g %s -###