1#
2# Copyright (c) 2022, Google, Inc. All rights reserved
3#
4# Permission is hereby granted, free of charge, to any person obtaining
5# a copy of this software and associated documentation files
6# (the "Software"), to deal in the Software without restriction,
7# including without limitation the rights to use, copy, modify, merge,
8# publish, distribute, sublicense, and/or sell copies of the Software,
9# and to permit persons to whom the Software is furnished to do so,
10# subject to the following conditions:
11#
12# The above copyright notice and this permission notice shall be
13# included in all copies or substantial portions of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22#
23
24LOCAL_DIR := $(GET_LOCAL_DIR)
25
26MODULE := $(LOCAL_DIR)
27
28LIBCXX_DIR = external/libcxx
29
30GLOBAL_INCLUDES += $(LIBCXX_DIR)/include
31GLOBAL_INCLUDES += $(LOCAL_DIR)/include
32
33# The header files change if they're being used to build the library.
34# For example, adding "public" methods that are only used internally.
35MODULE_CPPFLAGS += -D_LIBCPP_BUILDING_LIBRARY
36
37# libcxx defines fallback functions unless it knows they'll be found in libcxxabi.
38MODULE_CPPFLAGS += -DLIBCXX_BUILDING_LIBCXXABI
39
40# The following should be CXXFLAGS, compile.mk uses CPPFLAGS for C++ rather than
41# preprocessor flags and implicit variables are never used so it should not be
42# an issue.
43GLOBAL_CPPFLAGS += \
44	-D_LIBCPP_BUILD_STATIC \
45	-D_LIBCPP_HAS_MUSL_LIBC \
46	-D_LIBCPP_HAS_C11_FEATURES \
47
48# This enables a libcxx build flag which disables visibility attributes so that
49# the global -fvisibility=hidden flag that we set in engine.mk will apply to
50# this module's sources. -fvisibility=hidden is required for
51# -fvirtual-function-elimination which we use to remove dead floating point code
52# in libcxx.
53GLOBAL_CPPFLAGS += -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
54
55# This libcxx module implements an external threading API using LK's
56# thread.h/mutex.h.
57GLOBAL_CPPFLAGS += -D_LIBCPP_HAS_THREAD_API_EXTERNAL
58
59MODULE_SRCS := \
60	$(LIBCXX_DIR)/src/algorithm.cpp \
61	$(LIBCXX_DIR)/src/exception.cpp \
62	$(LIBCXX_DIR)/src/ios.cpp \
63	$(LIBCXX_DIR)/src/iostream.cpp \
64	$(LIBCXX_DIR)/src/locale.cpp \
65	$(LIBCXX_DIR)/src/memory.cpp \
66	$(LIBCXX_DIR)/src/mutex.cpp \
67	$(LIBCXX_DIR)/src/new.cpp \
68	$(LIBCXX_DIR)/src/string.cpp \
69	$(LIBCXX_DIR)/src/vector.cpp \
70
71
72MODULE_DEPS += \
73	trusty/kernel/lib/libcxxabi-trusty \
74
75include make/module.mk
76