diff options
author | Dan Albert <danalbert@google.com> | 2019-07-23 13:29:41 -0700 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2019-07-23 15:14:03 -0700 |
commit | 8144d214aed6d7bfc87b773782a9792f6609810d (patch) | |
tree | 38cde15dbf7655c858ee9812716e5b47bc144622 | |
parent | ebe828e0f9ec7cbaa7a8173703bf7a0457629a60 (diff) | |
download | libcxxabi-8144d214aed6d7bfc87b773782a9792f6609810d.tar.gz |
Move the demangler into its own library.
The demangler is quite large, and not commonly needed. If we remove
the use of the demangler from the default terminate handler and remove
the demangler from libc++abi.a, it won't cause dirty pages for every
libc++.so user on the system.
For those that do actually need the demangler, it has been moved into
a separate libc++demangle.a that must be linked explicitly. Some day
the build system could make the explicit link unnecessary, but not
currently. There are only a handful of users, so it's not a large
burden.
Test: make checkbuild
Test: external/libcxx/run_tests.py --bitness 32
Test: external/libcxx/run_tests.py --bitness 64
Test: adb shell librank | grep libc++
Bug: http://b/138245375
Change-Id: I344d4c6957b9b7180a9d825cb5119fa5b2ce61b6
-rw-r--r-- | Android.bp | 61 | ||||
-rw-r--r-- | src/cxa_default_handlers.cpp | 4 |
2 files changed, 41 insertions, 24 deletions
@@ -14,12 +14,44 @@ // limitations under the License. // -cc_library_static { - name: "libc++abi", - host_supported: true, +cc_defaults { + name: "libc++abi_defaults", vendor_available: true, recovery_available: true, native_bridge_supported: true, + include_dirs: ["external/libcxx/include"], + local_include_dirs: ["include"], + export_include_dirs: ["include"], + cflags: [ + "-Wall", + "-Werror", + ], + cppflags: [ + "-std=c++14", + "-fexceptions", + "-Wextra", + "-Wno-unused-function", + "-Wno-implicit-fallthrough", + // src/cxa_demangle.cpp:2591 -Wimplicit-fallthrough + ], + sanitize: { + never: true, + }, + stl: "none", + rtti: true, +} + +cc_library_static { + name: "libc++demangle", + defaults: ["libc++abi_defaults"], + host_supported: false, + srcs: ["src/cxa_demangle.cpp"], +} + +cc_library_static { + name: "libc++abi", + defaults: ["libc++abi_defaults"], + host_supported: true, srcs: [ "src/abort_message.cpp", "src/cxa_aux_runtime.cpp", @@ -41,26 +73,6 @@ cc_library_static { "src/stdlib_stdexcept.cpp", "src/stdlib_typeinfo.cpp", ], - include_dirs: ["external/libcxx/include"], - local_include_dirs: ["include"], - export_include_dirs: ["include"], - cflags: [ - "-Wall", - "-Werror", - ], - cppflags: [ - "-std=c++14", - "-fexceptions", - "-Wextra", - "-Wno-unused-function", - "-Wno-implicit-fallthrough", - // src/cxa_demangle.cpp:2591 -Wimplicit-fallthrough - ], - sanitize: { - never: true, - }, - stl: "none", - rtti: true, arch: { arm: { include_dirs: ["external/libunwind_llvm/include"], @@ -85,6 +97,8 @@ cc_library_static { target: { android: { cppflags: ["-DHAVE___CXA_THREAD_ATEXIT_IMPL"], + // Packaged in libc++demangle for Android to reduce bloat. + exclude_srcs: ["src/cxa_demangle.cpp"], }, darwin: { // libcxxabi really doesn't like the non-LLVM assembler on Darwin @@ -121,5 +135,4 @@ cc_library_static { ], } }, - } diff --git a/src/cxa_default_handlers.cpp b/src/cxa_default_handlers.cpp index f00e959..3dbde8d 100644 --- a/src/cxa_default_handlers.cpp +++ b/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<const __shim_type_info*>(exception_header->exceptionType); +#if !defined(__ANDROID__) // 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<const __shim_type_info*>(&typeid(std::exception)); |