From bbbe29de119843d6fd409c43f11b365f7de3b45c Mon Sep 17 00:00:00 2001 From: "mark@chromium.org" Date: Wed, 10 Dec 2014 16:08:09 +0000 Subject: Breakpad: Fix build with new clang versions. gcc has a single exception setting for all languages. Saying -fno-exceptions in gcc disables exceptions and cleanups for cc files, but has no effect for mm files. In clang, -fno-exceptions only disables c++ exceptions, but keeps objective-c exceptions and cleanups enabled. http://llvm.org/viewvc/llvm-project?view=revision&revision=220714 changed __EXCEPTIONS to be defined for clang when cleanups are enabled, independent of if c++ exceptions are enabled. (This was necessary to have clang work with glibc which looks at __EXCEPTIONS to decide if cleanups are enabled.) Breakpad tried to use __EXCEPTIONS to figure out if c++ exceptions are enabled. In cc files, this works: -fno-exceptions will disable c++ exceptions and cleanups. But in mm files, -fno-exceptions will disable c++ exceptions and objective-c exceptions will still be enabled, and so cleanups must run and hence __EXCEPTIONS is defined. To make things work with both old and new compilers, do the try/catch hack in mm files either if __EXCEPTIONS is not defined (for old compilers) or if the compiler is clang and __has_feature(cxx_exceptions) isn't set (which will work for new clangs too, and which cleanly maps to if c++ exceptions are enabled). Patch by Nico Weber Review URL: https://breakpad.appspot.com/1774002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1409 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/client/ios/Breakpad.mm | 2 +- src/client/mac/Framework/Breakpad.mm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/client/ios/Breakpad.mm b/src/client/ios/Breakpad.mm index ca856f8f..c56a6401 100644 --- a/src/client/ios/Breakpad.mm +++ b/src/client/ios/Breakpad.mm @@ -45,7 +45,7 @@ #import "client/mac/handler/protected_memory_allocator.h" #import "common/simple_string_dictionary.h" -#ifndef __EXCEPTIONS +#if !defined(__EXCEPTIONS) || (__clang__ && !__has_feature(cxx_exceptions)) // This file uses C++ try/catch (but shouldn't). Duplicate the macros from // allowing this file to work properly with // exceptions disabled even when other C++ libraries are used. #undef the try diff --git a/src/client/mac/Framework/Breakpad.mm b/src/client/mac/Framework/Breakpad.mm index 3b4b6674..1d2e519b 100644 --- a/src/client/mac/Framework/Breakpad.mm +++ b/src/client/mac/Framework/Breakpad.mm @@ -48,7 +48,7 @@ #import "common/mac/MachIPC.h" #import "common/simple_string_dictionary.h" -#ifndef __EXCEPTIONS +#if !defined(__EXCEPTIONS) || (__clang__ && !__has_feature(cxx_exceptions)) // This file uses C++ try/catch (but shouldn't). Duplicate the macros from // allowing this file to work properly with // exceptions disabled even when other C++ libraries are used. #undef the try -- cgit v1.2.1