Expand libcxx and add libcxxabi

Bug: 110158907
Change-Id: I38c7e50fd82332f666e9a9d513fb0c36f11afd95
diff --git a/lib/libcxxabi-trusty/rules.mk b/lib/libcxxabi-trusty/rules.mk
new file mode 100644
index 0000000..03fd122
--- /dev/null
+++ b/lib/libcxxabi-trusty/rules.mk
@@ -0,0 +1,44 @@
+LOCAL_DIR := $(GET_LOCAL_DIR)
+
+MODULE := $(LOCAL_DIR)
+
+LIBCXXABI_DIR = external/libcxxabi
+
+GLOBAL_INCLUDES += $(LIBCXXABI_DIR)/include
+
+MODULE_COMPILEFLAGS += -D_LIBCXXABI_BUILDING_LIBRARY -D_LIBCXXABI_HAS_NO_THREADS
+
+# Required if compiling without exceptions.
+MODULE_COMPILEFLAGS += -D_LIBCXXABI_NO_EXCEPTIONS
+
+# Required if compiling without RTTI, but also helps binary size.
+MODULE_COMPILEFLAGS += -DLIBCXXABI_SILENT_TERMINATE
+
+MODULE_SRCS := \
+	$(LIBCXXABI_DIR)/src/cxa_aux_runtime.cpp \
+	$(LIBCXXABI_DIR)/src/cxa_default_handlers.cpp \
+	$(LIBCXXABI_DIR)/src/cxa_demangle.cpp \
+	$(LIBCXXABI_DIR)/src/cxa_exception_storage.cpp \
+	$(LIBCXXABI_DIR)/src/cxa_guard.cpp \
+	$(LIBCXXABI_DIR)/src/cxa_handlers.cpp \
+	$(LIBCXXABI_DIR)/src/cxa_unexpected.cpp \
+	$(LIBCXXABI_DIR)/src/cxa_vector.cpp \
+	$(LIBCXXABI_DIR)/src/cxa_virtual.cpp \
+	$(LIBCXXABI_DIR)/src/stdlib_exception.cpp \
+	$(LIBCXXABI_DIR)/src/stdlib_stdexcept.cpp \
+	$(LIBCXXABI_DIR)/src/stdlib_typeinfo.cpp \
+	$(LIBCXXABI_DIR)/src/abort_message.cpp \
+	$(LIBCXXABI_DIR)/src/fallback_malloc.cpp \
+
+# Exceptions disabled
+MODULE_SRCS += \
+        $(LIBCXXABI_DIR)/src/cxa_noexception.cpp \
+
+# Files that do not compile without exceptions
+# $(LIBCXXABI_DIR)/src/cxa_exception.cpp \
+# $(LIBCXXABI_DIR)/src/cxa_personality.cpp \
+
+# Files that do not compile without RTTI
+# $(LIBCXXABI_DIR)/src/private_typeinfo.cpp \
+
+include make/module.mk
diff --git a/lib/libstdc++-trusty/rules.mk b/lib/libstdc++-trusty/rules.mk
index a6e7b18..6281e3f 100644
--- a/lib/libstdc++-trusty/rules.mk
+++ b/lib/libstdc++-trusty/rules.mk
@@ -8,12 +8,47 @@
 
 # The header files change if they're being used to build the library.
 # For example, adding "public" methods that are only used internally.
-MODULE_COMPILEFLAGS += -D_LIBCPP_BUILDING_LIBRARY
+MODULE_CPPFLAGS += -D_LIBCPP_BUILDING_LIBRARY
+
+# libcxx defines fallback functions unless it knows they'll be found in libcxxabi.
+MODULE_CPPFLAGS += -DLIBCXX_BUILDING_LIBCXXABI
+
+# Unfortunately these must be global because they change the contents of the header files.
+# _LIBCPP_BUILD_STATIC is obviously an issue because it can eliminate a virtual
+# function and lead to a missing vtable entry. The others are made global out of
+# caution.
+GLOBAL_CPPFLAGS += -D_LIBCPP_BUILD_STATIC -D_LIBCPP_HAS_NO_THREADS -D_LIBCPP_HAS_MUSL_LIBC
 
 MODULE_SRCS := \
+        $(LIBCXX_DIR)/src/any.cpp \
+        $(LIBCXX_DIR)/src/bind.cpp \
+        $(LIBCXX_DIR)/src/charconv.cpp \
+        $(LIBCXX_DIR)/src/chrono.cpp \
+        $(LIBCXX_DIR)/src/condition_variable.cpp \
+        $(LIBCXX_DIR)/src/debug.cpp \
+        $(LIBCXX_DIR)/src/exception.cpp \
+        $(LIBCXX_DIR)/src/future.cpp \
+        $(LIBCXX_DIR)/src/hash.cpp \
         $(LIBCXX_DIR)/src/memory.cpp \
+        $(LIBCXX_DIR)/src/mutex.cpp \
         $(LIBCXX_DIR)/src/new.cpp \
+        $(LIBCXX_DIR)/src/optional.cpp \
+        $(LIBCXX_DIR)/src/regex.cpp \
+        $(LIBCXX_DIR)/src/shared_mutex.cpp \
         $(LIBCXX_DIR)/src/string.cpp \
+        $(LIBCXX_DIR)/src/system_error.cpp \
+        $(LIBCXX_DIR)/src/thread.cpp \
+        $(LIBCXX_DIR)/src/typeinfo.cpp \
+        $(LIBCXX_DIR)/src/utility.cpp \
+        $(LIBCXX_DIR)/src/valarray.cpp \
+        $(LIBCXX_DIR)/src/variant.cpp \
         $(LIBCXX_DIR)/src/vector.cpp \
 
+
+# TODO files that require locale support.
+
+
+MODULE_DEPS := \
+        trusty/user/base/lib/libcxxabi-trusty \
+
 include make/module.mk