blob: d2e5c0665394c70c8fb9738ee915b3b046023cb5 [file] [log] [blame]
Christopher Ferrisfe6ff002014-01-30 01:04:29 -08001#
2# Copyright (C) 2014 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
Christopher Ferris1c82a522013-10-01 12:38:42 -070017LOCAL_PATH := $(call my-dir)
18
Christopher Ferris465f73c2015-03-10 16:40:25 -070019libunwind_build_host := false
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080020ifeq ($(HOST_OS),linux)
Christopher Ferris465f73c2015-03-10 16:40:25 -070021libunwind_build_host := true
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080022endif
23
Christopher Ferris76dbee52014-02-12 21:12:09 -080024# Set to true to enable a debug build of the libraries.
25# To control what is logged, set the environment variable UNW_DEBUG_LEVEL=x,
26# where x controls the verbosity (from 1 to 20).
Christopher Ferris465f73c2015-03-10 16:40:25 -070027libunwind_debug := false
Christopher Ferris76dbee52014-02-12 21:12:09 -080028
Christopher Ferris465f73c2015-03-10 16:40:25 -070029libunwind_common_cppflags := \
30 -Wno-old-style-cast \
Christopher Ferris4a590092015-03-07 11:32:24 -080031
Christopher Ferris465f73c2015-03-10 16:40:25 -070032libunwind_common_cflags := \
33 -Wno-unused-parameter \
34 -Werror \
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070035
36# gcc 4.8 appears to be overeager declaring that a variable is uninitialized,
37# under certain circumstances. Turn off this warning only for target so that
38# coverage is still present for the host code. When the entire build system
39# is switched to 4.9, then this can be removed.
Christopher Ferris465f73c2015-03-10 16:40:25 -070040libunwind_common_cflags_target := \
41 -Wno-maybe-uninitialized \
Christopher Ferrisd1c383c2014-04-09 16:48:26 -070042
Bernhard Rosenkraenzer25a2f1e2014-05-13 21:31:55 +020043# src/mi/backtrace.c is misdetected as a bogus header guard by clang 3.5
Chih-Hung Hsiehf760bf52014-10-03 09:33:43 -070044# src/x86_64/Gstash_frame.c has unnecessary calls to labs.
Christopher Ferris465f73c2015-03-10 16:40:25 -070045libunwind_common_clang_cflags += \
Chih-Hung Hsiehf760bf52014-10-03 09:33:43 -070046 -Wno-header-guard \
47 -Wno-absolute-value \
Bernhard Rosenkraenzer25a2f1e2014-05-13 21:31:55 +020048
Stephen Hinesbbd6a882015-03-31 09:37:48 -070049# The latest clang (r230699) does not allow SP/PC to be declared in inline asm lists.
50libunwind_common_clang_cflags += \
51 -Wno-inline-asm
52
Christopher Ferrisf7c36862015-04-15 14:52:09 -070053ifneq ($(libunwind_debug),true)
Christopher Ferris465f73c2015-03-10 16:40:25 -070054libunwind_common_cflags += \
55 -DHAVE_CONFIG_H \
56 -DNDEBUG \
57 -D_GNU_SOURCE \
Christopher Ferris9fc75e82014-01-26 21:39:06 -080058
Christopher Ferris76dbee52014-02-12 21:12:09 -080059else
Christopher Ferris465f73c2015-03-10 16:40:25 -070060libunwind_common_cflags += \
61 -DHAVE_CONFIG_H \
62 -DDEBUG \
63 -D_GNU_SOURCE \
64 -U_FORTIFY_SOURCE \
Christopher Ferris76dbee52014-02-12 21:12:09 -080065
66endif
Pavel Chupinf1f90e72013-12-04 13:29:29 +040067
Christopher Ferris465f73c2015-03-10 16:40:25 -070068libunwind_common_c_includes := \
69 $(LOCAL_PATH)/src \
70 $(LOCAL_PATH)/include \
Colin Cross26183d22014-01-24 15:59:56 -080071
Duane Sand5cd02e12014-06-05 23:38:56 -070072# Since mips and mips64 use the same source, only generate includes/srcs
73# for the below set of arches.
Christopher Ferris465f73c2015-03-10 16:40:25 -070074libunwind_generate_arches := arm arm64 mips x86 x86_64
Duane Sand5cd02e12014-06-05 23:38:56 -070075# The complete list of arches used by Android.build.mk to set arch
76# variables.
Christopher Ferris465f73c2015-03-10 16:40:25 -070077libunwind_arches := $(libunwind_generate_arches) mips64
Christopher Ferris1c82a522013-10-01 12:38:42 -070078
Christopher Ferris465f73c2015-03-10 16:40:25 -070079$(foreach arch,$(libunwind_generate_arches), \
80 $(eval libunwind_common_c_includes_$(arch) := $(LOCAL_PATH)/include/tdep-$(arch)))
Christopher Ferris1c82a522013-10-01 12:38:42 -070081
Christopher Ferrisfe6ff002014-01-30 01:04:29 -080082#-----------------------------------------------------------------------
83# libunwind shared library
84#-----------------------------------------------------------------------
85libunwind_src_files := \
Christopher Ferris465f73c2015-03-10 16:40:25 -070086 src/mi/init.c \
87 src/mi/flush_cache.c \
88 src/mi/mempool.c \
89 src/mi/strerror.c \
90 src/mi/backtrace.c \
91 src/mi/dyn-cancel.c \
92 src/mi/dyn-info-list.c \
93 src/mi/dyn-register.c \
94 src/mi/map.c \
95 src/mi/Lmap.c \
96 src/mi/Ldyn-extract.c \
97 src/mi/Lfind_dynamic_proc_info.c \
98 src/mi/Lget_proc_info_by_ip.c \
99 src/mi/Lget_proc_name.c \
100 src/mi/Lput_dynamic_unwind_info.c \
101 src/mi/Ldestroy_addr_space.c \
102 src/mi/Lget_reg.c \
103 src/mi/Lset_reg.c \
104 src/mi/Lget_fpreg.c \
105 src/mi/Lset_fpreg.c \
106 src/mi/Lset_caching_policy.c \
107 src/mi/Gdyn-extract.c \
108 src/mi/Gdyn-remote.c \
109 src/mi/Gfind_dynamic_proc_info.c \
110 src/mi/Gget_accessors.c \
111 src/mi/Gget_proc_info_by_ip.c \
112 src/mi/Gget_proc_name.c \
113 src/mi/Gput_dynamic_unwind_info.c \
114 src/mi/Gdestroy_addr_space.c \
115 src/mi/Gget_reg.c \
116 src/mi/Gset_reg.c \
117 src/mi/Gget_fpreg.c \
118 src/mi/Gset_fpreg.c \
119 src/mi/Gset_caching_policy.c \
120 src/dwarf/Lexpr.c \
121 src/dwarf/Lfde.c \
122 src/dwarf/Lparser.c \
123 src/dwarf/Lpe.c \
124 src/dwarf/Lstep_dwarf.c \
125 src/dwarf/Lfind_proc_info-lsb.c \
126 src/dwarf/Lfind_unwind_table.c \
127 src/dwarf/Gexpr.c \
128 src/dwarf/Gfde.c \
129 src/dwarf/Gfind_proc_info-lsb.c \
130 src/dwarf/Gfind_unwind_table.c \
131 src/dwarf/Gparser.c \
132 src/dwarf/Gpe.c \
133 src/dwarf/Gstep_dwarf.c \
134 src/dwarf/global.c \
135 src/os-common.c \
136 src/os-linux.c \
137 src/Los-common.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700138
Christopher Ferrisf7c36862015-04-15 14:52:09 -0700139# ptrace files for remote unwinding.
140libunwind_src_files += \
141 src/ptrace/_UPT_accessors.c \
142 src/ptrace/_UPT_access_fpreg.c \
143 src/ptrace/_UPT_access_mem.c \
144 src/ptrace/_UPT_access_reg.c \
145 src/ptrace/_UPT_create.c \
146 src/ptrace/_UPT_destroy.c \
147 src/ptrace/_UPT_find_proc_info.c \
148 src/ptrace/_UPT_get_dyn_info_list_addr.c \
149 src/ptrace/_UPT_put_unwind_info.c \
150 src/ptrace/_UPT_get_proc_name.c \
151 src/ptrace/_UPT_reg_offset.c \
152 src/ptrace/_UPT_resume.c \
153
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800154# Arch specific source files.
Christopher Ferris465f73c2015-03-10 16:40:25 -0700155$(foreach arch,$(libunwind_generate_arches), \
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800156 $(eval libunwind_src_files_$(arch) += \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700157 src/$(arch)/is_fpreg.c \
158 src/$(arch)/regname.c \
159 src/$(arch)/Gcreate_addr_space.c \
160 src/$(arch)/Gget_proc_info.c \
161 src/$(arch)/Gget_save_loc.c \
162 src/$(arch)/Gglobal.c \
163 src/$(arch)/Ginit.c \
164 src/$(arch)/Ginit_local.c \
165 src/$(arch)/Ginit_remote.c \
166 src/$(arch)/Gregs.c \
167 src/$(arch)/Gresume.c \
168 src/$(arch)/Gstep.c \
169 src/$(arch)/Lcreate_addr_space.c \
170 src/$(arch)/Lget_proc_info.c \
171 src/$(arch)/Lget_save_loc.c \
172 src/$(arch)/Lglobal.c \
173 src/$(arch)/Linit.c \
174 src/$(arch)/Linit_local.c \
175 src/$(arch)/Linit_remote.c \
176 src/$(arch)/Lregs.c \
177 src/$(arch)/Lresume.c \
178 src/$(arch)/Lstep.c \
179 ))
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800180
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800181libunwind_src_files_arm += \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700182 src/arm/getcontext.S \
183 src/arm/Gis_signal_frame.c \
184 src/arm/Gex_tables.c \
185 src/arm/Lis_signal_frame.c \
186 src/arm/Lex_tables.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700187
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800188libunwind_src_files_arm64 += \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700189 src/aarch64/Gis_signal_frame.c \
190 src/aarch64/Lis_signal_frame.c \
Christopher Ferris9fc75e82014-01-26 21:39:06 -0800191
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800192libunwind_src_files_mips += \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700193 src/mips/getcontext-android.S \
194 src/mips/Gis_signal_frame.c \
195 src/mips/Lis_signal_frame.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700196
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800197libunwind_src_files_x86 += \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700198 src/x86/getcontext-linux.S \
199 src/x86/Gos-linux.c \
200 src/x86/Los-linux.c \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700201
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800202libunwind_src_files_x86_64 += \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700203 src/x86_64/getcontext.S \
204 src/x86_64/Gstash_frame.c \
205 src/x86_64/Gtrace.c \
206 src/x86_64/Gos-linux.c \
207 src/x86_64/Lstash_frame.c \
208 src/x86_64/Ltrace.c \
209 src/x86_64/Los-linux.c \
210 src/x86_64/setcontext.S \
Pavel Chupinf1f90e72013-12-04 13:29:29 +0400211
Duane Sand5cd02e12014-06-05 23:38:56 -0700212# mips and mips64 use the same sources but define _MIP_SIM differently
213# to change the behavior.
214# mips uses o32 abi (_MIPS_SIM == _ABIO32).
215# mips64 uses n64 abi (_MIPS_SIM == _ABI64).
Christopher Ferris465f73c2015-03-10 16:40:25 -0700216libunwind_common_c_includes_mips64 := $(LOCAL_PATH)/include/tdep-mips
Duane Sand5cd02e12014-06-05 23:38:56 -0700217libunwind_src_files_mips64 := $(libunwind_src_files_mips)
218
219# 64-bit architectures
220libunwind_src_files_arm64 += src/elf64.c
221libunwind_src_files_mips64 += src/elf64.c
222libunwind_src_files_x86_64 += src/elf64.c
223
224# 32-bit architectures
225libunwind_src_files_arm += src/elf32.c
226libunwind_src_files_mips += src/elf32.c
227libunwind_src_files_x86 += src/elf32.c
228
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800229libunwind_shared_libraries_target := \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700230 libdl \
Christopher Ferris1c82a522013-10-01 12:38:42 -0700231
Dan Albert162c8cb2014-05-09 10:19:20 -0700232libunwind_ldflags_host := \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700233 -nostdlib
Dan Albert162c8cb2014-05-09 10:19:20 -0700234
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800235libunwind_ldlibs_host := \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700236 -lc \
237 -lpthread \
Christopher Ferrisf4a8df52014-03-07 19:40:06 -0800238
Trevor Drake9fcad642014-12-07 12:35:09 +0000239libunwind_export_c_include_dirs := \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700240 $(LOCAL_PATH)/include
Trevor Drake9fcad642014-12-07 12:35:09 +0000241
Christopher Ferrisf7c36862015-04-15 14:52:09 -0700242ifeq ($(libunwind_debug),true)
Christopher Ferris76dbee52014-02-12 21:12:09 -0800243libunwind_shared_libraries += \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700244 liblog \
Christopher Ferris76dbee52014-02-12 21:12:09 -0800245
246endif
247
Christopher Ferris465f73c2015-03-10 16:40:25 -0700248libunwind_module := libunwind
249libunwind_module_tag := optional
250libunwind_build_type := target
251libunwind_build_target := SHARED_LIBRARY
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800252include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris465f73c2015-03-10 16:40:25 -0700253libunwind_build_type := host
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800254include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris465f73c2015-03-10 16:40:25 -0700255libunwind_build_type := target
256libunwind_build_target := STATIC_LIBRARY
Dan Albert76728fb2014-05-09 13:51:35 -0700257include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris465f73c2015-03-10 16:40:25 -0700258libunwind_build_type := host
Dan Albert76728fb2014-05-09 13:51:35 -0700259include $(LOCAL_PATH)/Android.build.mk
260
Christopher Ferrisfe6ff002014-01-30 01:04:29 -0800261#-----------------------------------------------------------------------
Christopher Ferrisaa946482014-06-19 11:04:34 -0700262# libunwindbacktrace static library
263#-----------------------------------------------------------------------
264libunwindbacktrace_src_files += \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700265 src/unwind/BacktraceWrapper.c \
266 src/unwind/DeleteException.c \
267 src/unwind/FindEnclosingFunction.c \
268 src/unwind/ForcedUnwind.c \
269 src/unwind/GetBSP.c \
270 src/unwind/GetCFA.c \
271 src/unwind/GetDataRelBase.c \
272 src/unwind/GetGR.c \
273 src/unwind/GetIP.c \
274 src/unwind/GetIPInfo.c \
275 src/unwind/GetLanguageSpecificData.c \
276 src/unwind/GetRegionStart.c \
277 src/unwind/GetTextRelBase.c \
278 src/unwind/RaiseException.c \
279 src/unwind/Resume.c \
280 src/unwind/Resume_or_Rethrow.c \
281 src/unwind/SetGR.c \
282 src/unwind/SetIP.c \
Christopher Ferrisaa946482014-06-19 11:04:34 -0700283
284libunwindbacktrace_cflags += \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700285 -Wno-old-style-declaration \
Calin Juravle1265e5f2015-06-08 14:26:18 +0100286 -fvisibility=hidden
Christopher Ferrisaa946482014-06-19 11:04:34 -0700287
Christopher Ferris465f73c2015-03-10 16:40:25 -0700288libunwind_module := libunwindbacktrace
289libunwind_module_tag := optional
290libunwind_build_type := target
291libunwind_build_target := STATIC_LIBRARY
Christopher Ferrisaa946482014-06-19 11:04:34 -0700292libunwindbacktrace_whole_static_libraries := libunwind
293include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris465f73c2015-03-10 16:40:25 -0700294libunwind_build_type := host
Christopher Ferrisaa946482014-06-19 11:04:34 -0700295include $(LOCAL_PATH)/Android.build.mk
296
297#-----------------------------------------------------------------------
Christopher Ferris7c042422014-04-25 13:21:40 -0700298# libunwind testing
299#-----------------------------------------------------------------------
300libunwind-unit-tests_cflags := \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700301 -fno-builtin \
302 -O0 \
303 -g \
Christopher Ferris7c042422014-04-25 13:21:40 -0700304
305libunwind-unit-tests_c_includes := \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700306 $(LOCAL_PATH)/include \
Christopher Ferris7c042422014-04-25 13:21:40 -0700307
308libunwind-unit-tests_src_files := \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700309 android/tests/local_test.cpp \
Christopher Ferris7c042422014-04-25 13:21:40 -0700310
311libunwind-unit-tests_shared_libraries := \
Christopher Ferris465f73c2015-03-10 16:40:25 -0700312 libunwind \
Christopher Ferris7c042422014-04-25 13:21:40 -0700313
314libunwind-unit-tests_multilib := both
Christopher Ferris465f73c2015-03-10 16:40:25 -0700315libunwind_module := libunwind-unit-tests
316libunwind_module_tag := optional
317libunwind_build_type := target
318libunwind_build_target := NATIVE_TEST
Christopher Ferris7c042422014-04-25 13:21:40 -0700319include $(LOCAL_PATH)/Android.build.mk
Christopher Ferris465f73c2015-03-10 16:40:25 -0700320libunwind_build_type := host
Christopher Ferris7c042422014-04-25 13:21:40 -0700321include $(LOCAL_PATH)/Android.build.mk
322
323# Run the unit tests built for x86 or x86_64.
324ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
325ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86))
326LINKER = linker64
327TEST_SUFFIX = 64
328else
329LINKER = linker
330TEST_SUFFIX = 32
331endif
332
333libunwind-unit-tests-run-on-host: libunwind-unit-tests $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
334 if [ ! -d /system -o ! -d /system/bin ]; then \
335 echo "Attempting to create /system/bin"; \
336 sudo mkdir -p -m 0777 /system/bin; \
337 fi
338 mkdir -p $(TARGET_OUT_DATA)/local/tmp
339 cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin
340 cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
341 ANDROID_DATA=$(TARGET_OUT_DATA) \
342 ANDROID_ROOT=$(TARGET_OUT) \
343 LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \
344 $(TARGET_OUT_DATA_NATIVE_TESTS)/libunwind-unit-tests/libunwind-unit-tests$(TEST_SUFFIX) $(LIBUNWIND_TEST_FLAGS)
345endif