Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

Commit 91c21b2

Browse files
committed
Reland "Compile libcxx and libcxxabi (#190)"
This reverts commit f6b7397.
1 parent 7e555ae commit 91c21b2

File tree

4 files changed

+149
-9
lines changed

4 files changed

+149
-9
lines changed

build/config/BUILDCONFIG.gn

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,31 @@ if (custom_toolchain != "") {
632632
}
633633
}
634634

635+
# Sets default dependencies for executable and shared_library targets.
636+
#
637+
# Variables
638+
# no_default_deps: If true, no standard dependencies will be added.
639+
if (is_android) {
640+
foreach(_target_type,
641+
[
642+
"executable",
643+
"loadable_module",
644+
"shared_library",
645+
]) {
646+
template(_target_type) {
647+
target(_target_type, target_name) {
648+
forward_variables_from(invoker, "*", [ "no_default_deps" ])
649+
if (!defined(deps)) {
650+
deps = []
651+
}
652+
if (!defined(invoker.no_default_deps) || !invoker.no_default_deps) {
653+
deps += [ "//third_party/libcxx" ]
654+
}
655+
}
656+
}
657+
}
658+
}
659+
635660
# ==============================================================================
636661
# COMPONENT SETUP
637662
# ==============================================================================

build/config/compiler/BUILD.gn

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,6 @@ config("runtime_library") {
520520
# strange errors. The include ordering here is important; change with
521521
# caution.
522522
cflags += [
523-
"-isystem" + rebase_path("$android_libcpp_root/include", root_build_dir),
524-
"-isystem" + rebase_path(
525-
"$android_ndk_root/sources/cxx-stl/llvm-libc++abi/include",
526-
root_build_dir),
527523
"-isystem" +
528524
rebase_path("$android_ndk_root/sources/android/support/include",
529525
root_build_dir),
@@ -533,13 +529,14 @@ config("runtime_library") {
533529
"-D__ANDROID_API__=$android_api_level",
534530
]
535531

536-
lib_dirs += [ "$android_libcpp_root/libs/$android_app_abi" ]
537-
538-
libs += [
539-
"$android_libcpp_library",
540-
"c++abi",
532+
include_dirs = [
533+
"//third_party/libcxx/include",
534+
"//third_party/libcxxabi/include",
541535
]
542536

537+
# libunwind and libandroid_support also live in $android_libcpp_root.
538+
lib_dirs += [ "$android_libcpp_root/libs/$android_app_abi" ]
539+
543540
if (android_api_level < 21) {
544541
libs += [ "android_support" ]
545542
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Copyright 2013 The Flutter Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
config("libcxx_config") {
6+
include_dirs = [ "include" ]
7+
}
8+
9+
source_set("libcxx") {
10+
sources = [
11+
"src/algorithm.cpp",
12+
"src/any.cpp",
13+
"src/bind.cpp",
14+
"src/chrono.cpp",
15+
"src/condition_variable.cpp",
16+
"src/debug.cpp",
17+
"src/exception.cpp",
18+
"src/functional.cpp",
19+
"src/future.cpp",
20+
"src/hash.cpp",
21+
"src/ios.cpp",
22+
"src/iostream.cpp",
23+
"src/locale.cpp",
24+
"src/memory.cpp",
25+
"src/mutex.cpp",
26+
"src/new.cpp",
27+
"src/optional.cpp",
28+
"src/random.cpp",
29+
"src/regex.cpp",
30+
"src/shared_mutex.cpp",
31+
"src/stdexcept.cpp",
32+
"src/string.cpp",
33+
"src/strstream.cpp",
34+
"src/system_error.cpp",
35+
"src/thread.cpp",
36+
"src/typeinfo.cpp",
37+
"src/utility.cpp",
38+
"src/valarray.cpp",
39+
"src/variant.cpp",
40+
"src/vector.cpp",
41+
]
42+
43+
deps = [
44+
"//third_party/libcxxabi",
45+
]
46+
47+
public_configs = [
48+
":libcxx_config",
49+
"//third_party/libcxxabi:libcxxabi_config",
50+
]
51+
52+
defines = [
53+
"_LIBCPP_NO_EXCEPTIONS",
54+
"_LIBCPP_NO_RTTI",
55+
"_LIBCPP_BUILDING_LIBRARY",
56+
"LIBCXX_BUILDING_LIBCXXABI",
57+
]
58+
59+
if (is_clang) {
60+
# shared_mutex.cpp and debug.cpp are purposefully in violation.
61+
cflags_cc = [ "-Wno-thread-safety-analysis" ]
62+
}
63+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright 2013 The Flutter Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
import("$flutter_root/common/config.gni")
6+
7+
config("libcxxabi_config") {
8+
include_dirs = [ "include" ]
9+
}
10+
11+
source_set("libcxxabi") {
12+
visibility = [ "../libcxx" ]
13+
14+
sources = [
15+
"src/abort_message.cpp",
16+
"src/cxa_aux_runtime.cpp",
17+
"src/cxa_default_handlers.cpp",
18+
"src/cxa_exception_storage.cpp",
19+
"src/cxa_guard.cpp",
20+
"src/cxa_handlers.cpp",
21+
"src/cxa_noexception.cpp",
22+
"src/cxa_unexpected.cpp",
23+
"src/cxa_vector.cpp",
24+
"src/cxa_virtual.cpp",
25+
"src/fallback_malloc.cpp",
26+
"src/private_typeinfo.cpp",
27+
"src/stdlib_exception.cpp",
28+
"src/stdlib_stdexcept.cpp",
29+
"src/stdlib_typeinfo.cpp",
30+
]
31+
32+
# TODO(goderbauer): Remove this and add cxa_demangle.cpp to the regular source
33+
# list above when https://dart-review.googlesource.com/c/sdk/+/84831 has been
34+
# rolled into the engine.
35+
if (!is_android || flutter_runtime_mode != "release") {
36+
sources += [ "src/cxa_demangle.cpp" ]
37+
}
38+
39+
public_configs = [ ":libcxxabi_config" ]
40+
41+
defines = [
42+
"_LIBCXXABI_NO_EXCEPTIONS",
43+
"_LIBCXXABI_BUILDING_LIBRARY",
44+
"LIBCXXABI_SILENT_TERMINATE",
45+
]
46+
47+
# ICU uses RTTI, so we need to build libcxxabi with support for it,
48+
# https://github.com/flutter/flutter/issues/24535.
49+
configs -= [ "//build/config/compiler:no_rtti" ]
50+
51+
configs += [
52+
"//build/config/compiler:rtti",
53+
"//third_party/libcxx:libcxx_config",
54+
]
55+
}

0 commit comments

Comments
 (0)