[llvm-branch-commits] [libcxxabi] 866d480 - [libc++abi] Add an option to avoid demangling in terminate.
Author: Dan Albert Date: 2021-01-21T13:32:29-08:00 New Revision: 866d480fe0549d616bfdd69986dd07a7b2dc5b52 URL: https://github.com/llvm/llvm-project/commit/866d480fe0549d616bfdd69986dd07a7b2dc5b52 DIFF: https://github.com/llvm/llvm-project/commit/866d480fe0549d616bfdd69986dd07a7b2dc5b52.diff LOG: [libc++abi] Add an option to avoid demangling in terminate. We've been using this patch in Android so we can avoid including the demangler in libc++.so. It comes with a rather large cost in RSS and isn't commonly needed. Reviewed By: #libc_abi, compnerd Differential Revision: https://reviews.llvm.org/D88189 Added: Modified: libcxxabi/CMakeLists.txt libcxxabi/src/cxa_default_handlers.cpp Removed: diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index c8ab9d7acb1d..ede8bd71da4c 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -146,6 +146,8 @@ option(LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF) # The default terminate handler attempts to demangle uncaught exceptions, which # causes extra I/O and demangling code to be pulled in. option(LIBCXXABI_SILENT_TERMINATE "Set this to make the terminate handler default to a silent alternative" OFF) +option(LIBCXXABI_NON_DEMANGLING_TERMINATE "Set this to make the terminate handler +avoid demangling" OFF) if (NOT LIBCXXABI_ENABLE_SHARED AND NOT LIBCXXABI_ENABLE_STATIC) message(FATAL_ERROR "libc++abi must be built as either a shared or static library.") @@ -452,6 +454,10 @@ if (LIBCXXABI_SILENT_TERMINATE) add_definitions(-DLIBCXXABI_SILENT_TERMINATE) endif() +if (LIBCXXABI_NON_DEMANGLING_TERMINATE) + add_definitions(-DLIBCXXABI_NON_DEMANGLING_TERMINATE) +endif() + if (LIBCXXABI_BAREMETAL) add_definitions(-DLIBCXXABI_BAREMETAL) endif() diff --git a/libcxxabi/src/cxa_default_handlers.cpp b/libcxxabi/src/cxa_default_handlers.cpp index d2f823d2b778..a24ee0145343 100644 --- a/libcxxabi/src/cxa_default_handlers.cpp +++ b/libcxxabi/src/cxa_default_handlers.cpp @@ -45,6 +45,7 @@ static void demangling_terminate_handler() exception_header + 1; const __shim_type_info* thrown_type = static_cast(exception_header->exceptionType); +#if !defined(LIBCXXABI_NON_DEMANGLING_TERMINATE) // Try to get demangled name of thrown_type int status; char buf[1024]; @@ -52,6 +53,9 @@ static void demangling_terminate_handler() const char* name = __cxa_demangle(thrown_type->name(), buf, &len, &status); if (status != 0) name = thrown_type->name(); +#else +const char* name = thrown_type->name(); +#endif // If the uncaught exception can be caught with std::exception& const __shim_type_info* catch_type = static_cast(&typeid(std::exception)); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] 0849047 - Add a less ambiguous macro for Android version.
Author: Dan Albert Date: 2020-12-02T13:26:28-08:00 New Revision: 0849047860a343d8bcf1f828a82d585e89079943 URL: https://github.com/llvm/llvm-project/commit/0849047860a343d8bcf1f828a82d585e89079943 DIFF: https://github.com/llvm/llvm-project/commit/0849047860a343d8bcf1f828a82d585e89079943.diff LOG: Add a less ambiguous macro for Android version. Android has a handful of API levels relevant to developers described here: https://developer.android.com/studio/build#module-level. `__ANDROID_API__` is too vague and confuses a lot of people. Introduce a new macro name that is explicit about which one it represents. Keep the old name around because code has been using it for a decade. Added: Modified: clang/lib/Basic/Targets/OSTargets.h clang/test/Preprocessor/init.c Removed: diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h index 60e47bcacbf4..0d5d6f553093 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -383,8 +383,12 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public OSTargetInfo { Triple.getEnvironmentVersion(Maj, Min, Rev); this->PlatformName = "android"; this->PlatformMinVersion = VersionTuple(Maj, Min, Rev); - if (Maj) -Builder.defineMacro("__ANDROID_API__", Twine(Maj)); + if (Maj) { +Builder.defineMacro("__ANDROID_MIN_SDK_VERSION__", Twine(Maj)); +// This historical but ambiguous name for the minSdkVersion macro. Keep +// defined for compatibility. +Builder.defineMacro("__ANDROID_API__", "__ANDROID_MIN_SDK_VERSION__"); + } } else { Builder.defineMacro("__gnu_linux__"); } diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c index 079ec6e021f8..e599d9afb42e 100644 --- a/clang/test/Preprocessor/init.c +++ b/clang/test/Preprocessor/init.c @@ -1397,6 +1397,7 @@ // // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID %s // ANDROID-NOT:#define __ANDROID_API__ +// ANDROID-NOT:#define __ANDROID_MIN_SDK_VERSION__ // ANDROID:#define __ANDROID__ 1 // ANDROID-NOT:#define __gnu_linux__ // @@ -1407,7 +1408,8 @@ // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL // // RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID20 %s -// ANDROID20:#define __ANDROID_API__ 20 +// ANDROID20:#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__ +// ANDROID20:#define __ANDROID_MIN_SDK_VERSION__ 20 // ANDROID20:#define __ANDROID__ 1 // ANDROID-NOT:#define __gnu_linux__ // ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits