From aac222a433330671253ef3b42505ddb6c977ecb7 Mon Sep 17 00:00:00 2001 From: klzgrad Date: Sat, 30 Nov 2019 21:52:42 +0800 Subject: [PATCH] libc++: Disable exceptions and RTTI Except on Mac, where exceptions are required. And except on Android, where rtti is required. --- src/buildtools/third_party/libc++/BUILD.gn | 4 --- src/buildtools/third_party/libc++abi/BUILD.gn | 30 +++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/buildtools/third_party/libc++/BUILD.gn b/src/buildtools/third_party/libc++/BUILD.gn index 30fad21ed7..b29b678d6a 100644 --- a/src/buildtools/third_party/libc++/BUILD.gn +++ b/src/buildtools/third_party/libc++/BUILD.gn @@ -164,8 +164,6 @@ target(_libcxx_target_type, "libc++") { } configs -= [ "//build/config/compiler:chromium_code", - "//build/config/compiler:no_exceptions", - "//build/config/compiler:no_rtti", "//build/config/coverage:default_coverage", ] if ((is_android || is_apple) && libcxx_is_shared) { @@ -179,8 +177,6 @@ target(_libcxx_target_type, "libc++") { configs += [ ":config", "//build/config/compiler:no_chromium_code", - "//build/config/compiler:exceptions", - "//build/config/compiler:rtti", ] if (libcxx_is_shared && !is_win) { diff --git a/src/buildtools/third_party/libc++abi/BUILD.gn b/src/buildtools/third_party/libc++abi/BUILD.gn index bf3db7adc3..0321740443 100644 --- a/src/buildtools/third_party/libc++abi/BUILD.gn +++ b/src/buildtools/third_party/libc++abi/BUILD.gn @@ -98,4 +98,34 @@ source_set("libc++abi") { # libc++abi depends on libc++ internals. include_dirs = [ "//third_party/libc++/src/src" ] + if (!is_apple) { + sources -= [ + "//third_party/libc++abi/src/src/cxa_exception.cpp", + "//third_party/libc++abi/src/src/cxa_personality.cpp", + "//third_party/libc++abi/src/src/private_typeinfo.cpp", + ] + sources += [ + "//third_party/libc++abi/src/src/cxa_noexception.cpp", + ] + defines += [ "_LIBCXXABI_NO_EXCEPTIONS" ] + configs -= [ + "//build/config/compiler:exceptions", + "//build/config/compiler:rtti", + ] + configs += [ + "//build/config/compiler:no_exceptions", + "//build/config/compiler:no_rtti", + ] + } + if (is_android) { + sources += [ + "//third_party/libc++abi/src/src/private_typeinfo.cpp", + ] + configs -= [ + "//build/config/compiler:no_rtti", + ] + configs += [ + "//build/config/compiler:rtti", + ] + } }