• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1LOCAL_DIR := $(GET_LOCAL_DIR)
2
3MODULE := $(LOCAL_DIR)
4
5LIBCXX_DIR = external/libcxx
6
7MODULE_LICENSES += $(LIBCXX_DIR)/LICENSE.TXT
8
9MODULE_EXPORT_INCLUDES += $(LIBCXX_DIR)/include
10MODULE_EXPORT_INCLUDES += $(LOCAL_DIR)/include
11
12MODULE_SDK_HEADER_INSTALL_DIR := c++/v1
13
14# The header files change if they're being used to build the library.
15# For example, adding "public" methods that are only used internally.
16MODULE_CPPFLAGS += -D_LIBCPP_BUILDING_LIBRARY
17
18# libcxx defines fallback functions unless it knows they'll be found in libcxxabi.
19MODULE_CPPFLAGS += -DLIBCXX_BUILDING_LIBCXXABI
20
21# Unfortunately these must be global because they change the contents of the header files.
22# _LIBCPP_BUILD_STATIC is obviously an issue because it can eliminate a virtual
23# function and lead to a missing vtable entry. The others are made global out of
24# caution.
25MODULE_EXPORT_CPPFLAGS += -D_LIBCPP_BUILD_STATIC -D_LIBCPP_HAS_MUSL_LIBC
26
27# Use features supported by musl and Trusty
28MODULE_EXPORT_CPPFLAGS += \
29	-D_LIBCPP_HAS_QUICK_EXIT \
30	-D_LIBCPP_HAS_TIMESPEC_GET \
31	-D_LIBCPP_HAS_C11_FEATURES \
32
33# We need to pick a threading backend otherwise libcxx doesn't
34# export some C++ headers, e.g., <atomic>. musl supports pthreads
35# so we pick the pthreads backend, enabling those headers.
36# For now, any code that tries to use std::thread will fail to link
37# until Trusty implements the syscalls used by musl's pthreads.
38MODULE_EXPORT_CPPFLAGS += \
39	-D_LIBCPP_HAS_THREAD_API_PTHREAD \
40
41MODULE_SRCS := \
42        $(LIBCXX_DIR)/src/algorithm.cpp \
43        $(LIBCXX_DIR)/src/any.cpp \
44        $(LIBCXX_DIR)/src/bind.cpp \
45        $(LIBCXX_DIR)/src/charconv.cpp \
46        $(LIBCXX_DIR)/src/chrono.cpp \
47        $(LIBCXX_DIR)/src/condition_variable.cpp \
48        $(LIBCXX_DIR)/src/debug.cpp \
49        $(LIBCXX_DIR)/src/exception.cpp \
50        $(LIBCXX_DIR)/src/future.cpp \
51        $(LIBCXX_DIR)/src/hash.cpp \
52        $(LIBCXX_DIR)/src/ios.cpp \
53        $(LIBCXX_DIR)/src/iostream.cpp \
54        $(LIBCXX_DIR)/src/locale.cpp \
55        $(LIBCXX_DIR)/src/memory.cpp \
56        $(LIBCXX_DIR)/src/mutex.cpp \
57        $(LIBCXX_DIR)/src/new.cpp \
58        $(LIBCXX_DIR)/src/optional.cpp \
59        $(LIBCXX_DIR)/src/regex.cpp \
60        $(LIBCXX_DIR)/src/shared_mutex.cpp \
61        $(LIBCXX_DIR)/src/stdexcept.cpp \
62        $(LIBCXX_DIR)/src/string.cpp \
63        $(LIBCXX_DIR)/src/strstream.cpp \
64        $(LIBCXX_DIR)/src/system_error.cpp \
65        $(LIBCXX_DIR)/src/thread.cpp \
66        $(LIBCXX_DIR)/src/typeinfo.cpp \
67        $(LIBCXX_DIR)/src/utility.cpp \
68        $(LIBCXX_DIR)/src/valarray.cpp \
69        $(LIBCXX_DIR)/src/variant.cpp \
70        $(LIBCXX_DIR)/src/vector.cpp \
71
72
73# TODO add src/random.cpp when there is support for getting entropy.
74
75MODULE_LIBRARY_DEPS += \
76        trusty/user/base/lib/libcxxabi-trusty \
77        trusty/user/base/lib/libc-trusty \
78
79include make/library.mk
80