aboutsummaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2016-01-28 12:53:55 -0800
committerDan Albert <danalbert@google.com>2016-01-29 15:30:09 -0800
commit4ad37769ac7d016462d2416942594622863a9b0e (patch)
tree818a53e21dd68475af39e4dbe0af4a69b5c642bf /sources
parent4154c6586c37a184086c7bfac3ac1c5a1a35a6d9 (diff)
downloadndk-4ad37769ac7d016462d2416942594622863a9b0e.tar.gz
Build libc++abi components as separate libraries.
For exception unwinding to work properly on ARM, we need to make sure we're using the LLVM unwinder everywhere. To do this, we need to link it into each object. As such, we need to build it as a separate library rather than including the sources in libc++. Do the same with libc++abi while we're at it since this makes the makefiles more tractable. Bug: http://b/26194502 Change-Id: I96ebc4edfcbda048689fc6f0d87d0651cb4dc8e4
Diffstat (limited to 'sources')
-rw-r--r--sources/cxx-stl/llvm-libc++/Android.mk143
-rwxr-xr-xsources/cxx-stl/llvm-libc++/build.py13
-rw-r--r--sources/cxx-stl/llvm-libc++abi/Android.mk105
-rw-r--r--sources/cxx-stl/llvm-libc++abi/Application.mk18
-rw-r--r--sources/cxx-stl/llvm-libc++abi/sources.mk35
5 files changed, 193 insertions, 121 deletions
diff --git a/sources/cxx-stl/llvm-libc++/Android.mk b/sources/cxx-stl/llvm-libc++/Android.mk
index ef46ee130..dad7f74ee 100644
--- a/sources/cxx-stl/llvm-libc++/Android.mk
+++ b/sources/cxx-stl/llvm-libc++/Android.mk
@@ -17,82 +17,51 @@ ifndef LIBCXX_FORCE_REBUILD
endif
endif
-llvm_libc++_includes := $(LOCAL_PATH)/libcxx/include
-llvm_libc++_export_includes := $(llvm_libc++_includes)
-llvm_libc++_sources := \
- algorithm.cpp \
- bind.cpp \
- chrono.cpp \
- condition_variable.cpp \
- debug.cpp \
- exception.cpp \
- future.cpp \
- hash.cpp \
- ios.cpp \
- iostream.cpp \
- locale.cpp \
- memory.cpp \
- mutex.cpp \
- new.cpp \
- optional.cpp \
- random.cpp \
- regex.cpp \
- shared_mutex.cpp \
- stdexcept.cpp \
- string.cpp \
- strstream.cpp \
- system_error.cpp \
- thread.cpp \
- typeinfo.cpp \
- utility.cpp \
- valarray.cpp \
- support/android/locale_android.cpp
-
-llvm_libc++_sources := $(llvm_libc++_sources:%=libcxx/src/%)
+libcxx_includes := $(LOCAL_PATH)/libcxx/include
+libcxx_export_includes := $(libcxx_includes)
+libcxx_sources := \
+ algorithm.cpp \
+ bind.cpp \
+ chrono.cpp \
+ condition_variable.cpp \
+ debug.cpp \
+ exception.cpp \
+ future.cpp \
+ hash.cpp \
+ ios.cpp \
+ iostream.cpp \
+ locale.cpp \
+ memory.cpp \
+ mutex.cpp \
+ new.cpp \
+ optional.cpp \
+ random.cpp \
+ regex.cpp \
+ shared_mutex.cpp \
+ stdexcept.cpp \
+ string.cpp \
+ strstream.cpp \
+ system_error.cpp \
+ thread.cpp \
+ typeinfo.cpp \
+ utility.cpp \
+ valarray.cpp \
+ support/android/locale_android.cpp
+
+libcxx_sources := $(libcxx_sources:%=libcxx/src/%)
# For now, this library can only be used to build C++11 binaries.
-llvm_libc++_export_cxxflags := -std=c++11
+libcxx_export_cxxflags := -std=c++11
ifeq (,$(filter clang%,$(NDK_TOOLCHAIN_VERSION)))
# Add -fno-strict-aliasing because __list_imp::_end_ breaks TBAA rules by declaring
# simply as __list_node_base then casted to __list_node derived from that. See
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61571 for details
-llvm_libc++_export_cxxflags += -fno-strict-aliasing
+libcxx_export_cxxflags += -fno-strict-aliasing
endif
-llvm_libc++_cxxflags := $(llvm_libc++_export_cxxflags)
-llvm_libc++_cflags :=
-
-libcxxabi_sources_dir := $(strip $(wildcard $(LOCAL_PATH)/../llvm-libc++abi))
-ifdef libcxxabi_sources_dir
- libcxxabi_sources_prefix := ../llvm-libc++abi
-else
- libcxxabi_sources_dir := $(strip $(wildcard $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi))
- ifndef libcxxabi_sources_dir
- $(error Cannot find libcxxabi sources directory!!)
- endif
- libcxxabi_sources_prefix := $(libcxxabi_sources_dir)
-endif
-
-include $(libcxxabi_sources_dir)/sources.mk
-
-ifneq (,$(filter armeabi%,$(TARGET_ARCH_ABI)))
-# for armeabi*, use llvm libunwind
-llvm_libc++_sources += $(addprefix $(libcxxabi_sources_prefix:%/=%)/,$(libcxxabi_src_files))
-llvm_libc++_cxxflags += -DLIBCXXABI_USE_LLVM_UNWINDER=1 -D__STDC_FORMAT_MACROS
-else
-llvm_libc++_sources += $(addprefix $(libcxxabi_sources_prefix:%/=%)/,$(libcxxabi_src_base_files))
-llvm_libc++_cxxflags += -DLIBCXXABI_USE_LLVM_UNWINDER=0
-endif
-
-libcxx_ldlibs :=
-ifeq ($(TARGET_ARCH_ABI),armeabi)
- libcxx_ldlibs += -latomic
-endif
-
-llvm_libc++_includes += $(libcxxabi_c_includes)
-llvm_libc++_export_includes += $(libcxxabi_c_includes)
-llvm_libc++_cflags += -D__STDC_FORMAT_MACROS
+libcxx_cxxflags := $(libcxx_export_cxxflags)
+libcxx_cflags := -D__STDC_FORMAT_MACROS
ifneq ($(LIBCXX_FORCE_REBUILD),true)
@@ -103,15 +72,15 @@ android_support_c_includes := $(LOCAL_PATH)/../../android/support/include
include $(CLEAR_VARS)
LOCAL_MODULE := c++_static
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/lib$(LOCAL_MODULE)$(TARGET_LIB_EXTENSION)
-LOCAL_EXPORT_C_INCLUDES := $(llvm_libc++_export_includes) $(android_support_c_includes)
-LOCAL_EXPORT_CPPFLAGS := $(llvm_libc++_export_cxxflags)
+LOCAL_EXPORT_C_INCLUDES := $(libcxx_export_includes) $(android_support_c_includes)
+LOCAL_EXPORT_CPPFLAGS := $(libcxx_export_cxxflags)
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := c++_shared
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/lib$(LOCAL_MODULE)$(TARGET_SONAME_EXTENSION)
-LOCAL_EXPORT_C_INCLUDES := $(llvm_libc++_export_includes) $(android_support_c_includes)
-LOCAL_EXPORT_CPPFLAGS := $(llvm_libc++_export_cxxflags)
+LOCAL_EXPORT_C_INCLUDES := $(libcxx_export_includes) $(android_support_c_includes)
+LOCAL_EXPORT_CPPFLAGS := $(libcxx_export_cxxflags)
include $(PREBUILT_SHARED_LIBRARY)
else
@@ -121,25 +90,35 @@ $(call ndk_log,Rebuilding libc++ libraries from sources)
include $(CLEAR_VARS)
LOCAL_MODULE := c++_static
-LOCAL_SRC_FILES := $(llvm_libc++_sources)
-LOCAL_C_INCLUDES := $(android_support_c_includes) $(llvm_libc++_includes)
-LOCAL_CFLAGS := $(llvm_libc++_cflags)
-LOCAL_CPPFLAGS := $(llvm_libc++_cxxflags)
+LOCAL_SRC_FILES := $(libcxx_sources)
+LOCAL_C_INCLUDES := $(android_support_c_includes) $(libcxx_includes)
+LOCAL_CFLAGS := $(libcxx_cflags)
+LOCAL_CPPFLAGS := $(libcxx_cxxflags)
LOCAL_CPP_FEATURES := rtti exceptions
-LOCAL_EXPORT_C_INCLUDES := $(llvm_libc++_export_includes)
-LOCAL_EXPORT_CPPFLAGS := $(llvm_libc++_export_cxxflags)
-LOCAL_STATIC_LIBRARIES := android_support # Needed for export includes.
+LOCAL_EXPORT_C_INCLUDES := $(libcxx_export_includes)
+LOCAL_EXPORT_CPPFLAGS := $(libcxx_export_cxxflags)
+LOCAL_STATIC_LIBRARIES := libc++abi android_support
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := c++_shared
LOCAL_WHOLE_STATIC_LIBRARIES := c++_static
-LOCAL_EXPORT_C_INCLUDES := $(llvm_libc++_export_includes)
-LOCAL_EXPORT_CPPFLAGS := $(llvm_libc++_export_cxxflags)
-LOCAL_STATIC_LIBRARIES := android_support
-LOCAL_LDLIBS := $(libcxx_ldlibs)
+LOCAL_EXPORT_C_INCLUDES := $(libcxx_export_includes)
+LOCAL_EXPORT_CPPFLAGS := $(libcxx_export_cxxflags)
+LOCAL_STATIC_LIBRARIES := libc++abi android_support
+
+# We use the LLVM unwinder for all the 32-bit ARM targets.
+ifneq (,$(filter armeabi%,$(TARGET_ARCH_ABI)))
+ LOCAL_STATIC_LIBRARIES += libunwind
+endif
+
+# But only need -latomic for armeabi.
+ifeq ($(TARGET_ARCH_ABI),armeabi)
+ LOCAL_LDLIBS := -latomic
+endif
include $(BUILD_SHARED_LIBRARY)
endif # LIBCXX_FORCE_REBUILD == true
$(call import-module, android/support)
+$(call import-module, cxx-stl/llvm-libc++abi)
diff --git a/sources/cxx-stl/llvm-libc++/build.py b/sources/cxx-stl/llvm-libc++/build.py
index 270dfb5bc..682e03006 100755
--- a/sources/cxx-stl/llvm-libc++/build.py
+++ b/sources/cxx-stl/llvm-libc++/build.py
@@ -93,10 +93,15 @@ def main(args):
static_lib_dir = os.path.join(obj_out, 'local', abi)
install_dir = os.path.join(lib_out, abi)
- shutil.copy2(os.path.join(static_lib_dir, 'libc++_static.a'),
- install_dir)
- shutil.copy2(os.path.join(static_lib_dir, 'libandroid_support.a'),
- install_dir)
+ if is_arm:
+ shutil.copy2(
+ os.path.join(static_lib_dir, 'libunwind.a'), install_dir)
+
+ shutil.copy2(os.path.join(static_lib_dir, 'libc++abi.a'), install_dir)
+ shutil.copy2(
+ os.path.join(static_lib_dir, 'libandroid_support.a'), install_dir)
+ shutil.copy2(
+ os.path.join(static_lib_dir, 'libc++_static.a'), install_dir)
build_support.make_package('libcxx', libcxx_path, args.dist_dir)
diff --git a/sources/cxx-stl/llvm-libc++abi/Android.mk b/sources/cxx-stl/llvm-libc++abi/Android.mk
new file mode 100644
index 000000000..5555ca74f
--- /dev/null
+++ b/sources/cxx-stl/llvm-libc++abi/Android.mk
@@ -0,0 +1,105 @@
+#
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+libcxxabi_src_files := \
+ libcxxabi/src/abort_message.cpp \
+ libcxxabi/src/cxa_aux_runtime.cpp \
+ libcxxabi/src/cxa_default_handlers.cpp \
+ libcxxabi/src/cxa_demangle.cpp \
+ libcxxabi/src/cxa_exception.cpp \
+ libcxxabi/src/cxa_exception_storage.cpp \
+ libcxxabi/src/cxa_guard.cpp \
+ libcxxabi/src/cxa_handlers.cpp \
+ libcxxabi/src/cxa_new_delete.cpp \
+ libcxxabi/src/cxa_personality.cpp \
+ libcxxabi/src/cxa_thread_atexit.cpp \
+ libcxxabi/src/cxa_unexpected.cpp \
+ libcxxabi/src/cxa_vector.cpp \
+ libcxxabi/src/cxa_virtual.cpp \
+ libcxxabi/src/exception.cpp \
+ libcxxabi/src/private_typeinfo.cpp \
+ libcxxabi/src/stdexcept.cpp \
+ libcxxabi/src/typeinfo.cpp
+
+libunwind_src_files := \
+ libcxxabi/src/Unwind/libunwind.cpp \
+ libcxxabi/src/Unwind/Unwind-EHABI.cpp \
+ libcxxabi/src/Unwind/Unwind-sjlj.c \
+ libcxxabi/src/Unwind/UnwindLevel1.c \
+ libcxxabi/src/Unwind/UnwindLevel1-gcc-ext.c \
+ libcxxabi/src/Unwind/UnwindRegistersRestore.S \
+ libcxxabi/src/Unwind/UnwindRegistersSave.S
+
+libcxxabi_includes := \
+ $(LOCAL_PATH)/libcxxabi/include \
+ $(LOCAL_PATH)/../llvm-libc++/libcxx/include \
+
+libcxxabi_cflags := -D__STDC_FORMAT_MACROS
+libcxxabi_cppflags := -std=c++11
+
+ifneq (,$(filter armeabi%,$(TARGET_ARCH_ABI)))
+ libcxxabi_cppflags += -DLIBCXXABI_USE_LLVM_UNWINDER=1
+else
+ libcxxabi_cppflags += -DLIBCXXABI_USE_LLVM_UNWINDER=0
+endif
+
+ifneq ($(LIBCXX_FORCE_REBUILD),true) # Using prebuilt
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libunwind
+LOCAL_SRC_FILES := ../llvm-libc++/libs/$(TARGET_ARCH_ABI)/$(LOCAL_MODULE)$(TARGET_LIB_EXTENSION)
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/libcxxabi/include
+include $(PREBUILT_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libc++abi
+LOCAL_SRC_FILES := ../llvm-libc++/libs/$(TARGET_ARCH_ABI)/$(LOCAL_MODULE)$(TARGET_LIB_EXTENSION)
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/libcxxabi/include
+include $(PREBUILT_STATIC_LIBRARY)
+
+else # Building
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libunwind
+LOCAL_SRC_FILES := $(libunwind_src_files)
+LOCAL_C_INCLUDES := $(libcxxabi_includes)
+LOCAL_CFLAGS := $(libcxxabi_cflags) -fvisibility=hidden
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/libcxxabi/include
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libc++abi
+LOCAL_SRC_FILES := $(libcxxabi_src_files)
+LOCAL_C_INCLUDES := $(libcxxabi_includes)
+LOCAL_CPPFLAGS := $(libcxxabi_cppflags)
+LOCAL_CPP_FEATURES := rtti exceptions
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/libcxxabi/include
+LOCAL_STATIC_LIBRARIES := android_support
+
+# Unlike the platform build, ndk-build will actually perform dependency checking
+# on static libraries and topologically sort them to determine link order.
+# Though there is no link step, without this we may link libunwind before
+# libc++abi, which won't succeed.
+ifneq (,$(filter armeabi%,$(TARGET_ARCH_ABI)))
+ LOCAL_STATIC_LIBRARIES += libunwind
+endif
+include $(BUILD_STATIC_LIBRARY)
+
+endif # Prebuilt/building
+
+$(call import-module, android/support)
diff --git a/sources/cxx-stl/llvm-libc++abi/Application.mk b/sources/cxx-stl/llvm-libc++abi/Application.mk
new file mode 100644
index 000000000..f98280d37
--- /dev/null
+++ b/sources/cxx-stl/llvm-libc++abi/Application.mk
@@ -0,0 +1,18 @@
+#
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+NDK_TOOLCHAIN_VERSION := clang
+APP_STL := none
diff --git a/sources/cxx-stl/llvm-libc++abi/sources.mk b/sources/cxx-stl/llvm-libc++abi/sources.mk
deleted file mode 100644
index 40ef4eadb..000000000
--- a/sources/cxx-stl/llvm-libc++abi/sources.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-libcxxabi_path := $(call my-dir)
-
-libcxxabi_src_base_files := \
- libcxxabi/src/abort_message.cpp \
- libcxxabi/src/cxa_aux_runtime.cpp \
- libcxxabi/src/cxa_default_handlers.cpp \
- libcxxabi/src/cxa_demangle.cpp \
- libcxxabi/src/cxa_exception.cpp \
- libcxxabi/src/cxa_exception_storage.cpp \
- libcxxabi/src/cxa_guard.cpp \
- libcxxabi/src/cxa_handlers.cpp \
- libcxxabi/src/cxa_new_delete.cpp \
- libcxxabi/src/cxa_personality.cpp \
- libcxxabi/src/cxa_thread_atexit.cpp \
- libcxxabi/src/cxa_unexpected.cpp \
- libcxxabi/src/cxa_vector.cpp \
- libcxxabi/src/cxa_virtual.cpp \
- libcxxabi/src/exception.cpp \
- libcxxabi/src/private_typeinfo.cpp \
- libcxxabi/src/stdexcept.cpp \
- libcxxabi/src/typeinfo.cpp
-
-libcxxabi_src_unwind_files := \
- libcxxabi/src/Unwind/libunwind.cpp \
- libcxxabi/src/Unwind/Unwind-EHABI.cpp \
- libcxxabi/src/Unwind/Unwind-sjlj.c \
- libcxxabi/src/Unwind/UnwindLevel1.c \
- libcxxabi/src/Unwind/UnwindLevel1-gcc-ext.c \
- libcxxabi/src/Unwind/UnwindRegistersRestore.S \
- libcxxabi/src/Unwind/UnwindRegistersSave.S
-
-libcxxabi_src_files := $(libcxxabi_src_base_files) $(libcxxabi_src_unwind_files)
-
-libcxxabi_c_includes := $(libcxxabi_path)/libcxxabi/include
-