From 4f3b7565cdea35b49feb162ee2c05fdb851c44ef Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Fri, 30 Oct 2015 16:30:41 +0000 Subject: [PATCH] Disable SjLj exceptions for watchOS git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251709 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/ToolChain.h | 4 +++- lib/Driver/ToolChains.cpp | 16 ++++++++++++---- lib/Driver/ToolChains.h | 8 +++++--- lib/Driver/Tools.cpp | 2 +- test/Driver/arch-armv7k.c | 1 + 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h index edbf56200f..58e7c724cd 100644 --- a/include/clang/Driver/ToolChain.h +++ b/include/clang/Driver/ToolChain.h @@ -304,7 +304,9 @@ public: virtual bool GetDefaultStandaloneDebug() const { return false; } /// UseSjLjExceptions - Does this tool chain use SjLj exceptions. - virtual bool UseSjLjExceptions() const { return false; } + virtual bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const { + return false; + } /// getThreadModel() - Which thread model does this target use? virtual std::string getThreadModel() const { return "posix"; } diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index b65c5c1360..43a8ff657d 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -1037,10 +1037,18 @@ bool MachO::UseDwarfDebugFlags() const { return false; } -bool Darwin::UseSjLjExceptions() const { +bool Darwin::UseSjLjExceptions(const ArgList &Args) const { // Darwin uses SjLj exceptions on ARM. - return (getTriple().getArch() == llvm::Triple::arm || - getTriple().getArch() == llvm::Triple::thumb); + if (getTriple().getArch() != llvm::Triple::arm && + getTriple().getArch() != llvm::Triple::thumb) + return false; + + // We can't check directly for watchOS here. ComputeLLVMTriple only + // fills in the ArchName correctly. + llvm::Triple Triple(ComputeLLVMTriple(Args)); + return !(Triple.getArchName() == "armv7k" || + Triple.getArchName() == "thumbv7k"); + } bool MachO::isPICDefault() const { return true; } @@ -2952,7 +2960,7 @@ Tool *FreeBSD::buildAssembler() const { Tool *FreeBSD::buildLinker() const { return new tools::freebsd::Linker(*this); } -bool FreeBSD::UseSjLjExceptions() const { +bool FreeBSD::UseSjLjExceptions(const ArgList &Args) const { // FreeBSD uses SjLj exceptions on ARM oabi. switch (getTriple().getEnvironment()) { case llvm::Triple::GNUEABIHF: diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index d88403239f..77433789f9 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -339,7 +339,9 @@ public: bool UseDwarfDebugFlags() const override; - bool UseSjLjExceptions() const override { return false; } + bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override { + return false; + } /// } }; @@ -528,7 +530,7 @@ public: void CheckObjCARC() const override; - bool UseSjLjExceptions() const override; + bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override; SanitizerMask getSupportedSanitizers() const override; }; @@ -714,7 +716,7 @@ public: const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; - bool UseSjLjExceptions() const override; + bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override; bool isPIEDefault() const override; SanitizerMask getSupportedSanitizers() const override; unsigned GetDefaultDwarfVersion() const override { return 2; } diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 42a168584c..e72e4bdcb2 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -4824,7 +4824,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, addExceptionArgs(Args, InputType, getToolChain(), KernelOrKext, objcRuntime, CmdArgs); - if (getToolChain().UseSjLjExceptions()) + if (getToolChain().UseSjLjExceptions(Args)) CmdArgs.push_back("-fsjlj-exceptions"); // C++ "sane" operator new. diff --git a/test/Driver/arch-armv7k.c b/test/Driver/arch-armv7k.c index 7f5923e7dd..190d8999ab 100644 --- a/test/Driver/arch-armv7k.c +++ b/test/Driver/arch-armv7k.c @@ -2,3 +2,4 @@ // RUN: %clang -target x86_64-apple-macosx10.9 -arch armv7k -c %s -### 2>&1 | FileCheck %s // CHECK: "-cc1"{{.*}} "-target-cpu" "cortex-a7" +// CHECK-NOT: "-fsjlj-exceptions" -- 2.50.1