From: Akira Hatanaka Date: Mon, 21 Aug 2017 22:46:46 +0000 (+0000) Subject: [Driver][Darwin] Do not pass -munwind-table if -fno-excpetions is X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f4e3d63a31ea539b2afe20cd314ea3842b28dd51;p=clang [Driver][Darwin] Do not pass -munwind-table if -fno-excpetions is supplied. With this change, -fno-exceptions disables unwind tables unless -funwind-tables is supplied too or the target is x86-64 (x86-64 requires emitting unwind tables). rdar://problem/33934446 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311397 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/Darwin.cpp b/lib/Driver/ToolChains/Darwin.cpp index f67e36ef63..84d684c05b 100644 --- a/lib/Driver/ToolChains/Darwin.cpp +++ b/lib/Driver/ToolChains/Darwin.cpp @@ -1845,7 +1845,12 @@ Darwin::TranslateArgs(const DerivedArgList &Args, StringRef BoundArch, } bool MachO::IsUnwindTablesDefault(const ArgList &Args) const { - return !UseSjLjExceptions(Args); + // Unwind tables are not emitted if -fno-exceptions is supplied (except when + // targeting x86_64). + return getArch() == llvm::Triple::x86_64 || + (!UseSjLjExceptions(Args) && + Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, + true)); } bool MachO::UseDwarfDebugFlags() const { diff --git a/test/Driver/clang-translation.c b/test/Driver/clang-translation.c index 545951d5aa..3b30f7af76 100644 --- a/test/Driver/clang-translation.c +++ b/test/Driver/clang-translation.c @@ -73,6 +73,10 @@ // RUN: FileCheck -check-prefix=ARM64-APPLE %s // ARM64-APPLE: -munwind-table +// RUN: %clang -target arm64-apple-ios10 -fno-exceptions -### -S %s -arch arm64 2>&1 | \ +// RUN: FileCheck -check-prefix=ARM64-APPLE-EXCEP %s +// ARM64-APPLE-EXCEP-NOT: -munwind-table + // RUN: %clang -target armv7k-apple-watchos4.0 -### -S %s -arch armv7k 2>&1 | \ // RUN: FileCheck -check-prefix=ARMV7K-APPLE %s // ARMV7K-APPLE: -munwind-table