blob: 684e611a72102fc534653a5b68144cd1b6151de9 [file] [log] [blame]
Dan Willemsen2e1591b2016-07-12 17:20:18 -07001//
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
17cc_defaults {
18 name: "libbacktrace_common",
19
20 cflags: [
21 "-Wall",
22 "-Werror",
23 ],
Dan Willemsen2e1591b2016-07-12 17:20:18 -070024
Colin Crossda9bd592016-12-14 17:24:46 -080025 // The latest clang (r230699) does not allow SP/PC to be declared in inline asm lists.
Dan Willemsen2e1591b2016-07-12 17:20:18 -070026 clang_cflags: ["-Wno-inline-asm"],
27
Dan Willemsen2e1591b2016-07-12 17:20:18 -070028 include_dirs: ["external/libunwind/include/tdep"],
29
30 // TODO: LLVM_DEVICE_BUILD_MK
31 // TODO: LLVM_HOST_BUILD_MK
32
33 target: {
34 host: {
35 // -fno-omit-frame-pointer should be set for host build. Because currently
36 // libunwind can't recognize .debug_frame using dwarf version 4, and it relies
37 // on stack frame pointer to do unwinding on x86.
38 // $(LLVM_HOST_BUILD_MK) overwrites -fno-omit-frame-pointer. so the below line
39 // must be after the include.
40 cflags: [
41 "-Wno-extern-c-compat",
42 "-fno-omit-frame-pointer",
43 ],
44 },
45
46 darwin: {
47 enabled: false,
48 },
49 },
50
51 multilib: {
52 lib32: {
53 suffix: "32",
54 },
55 lib64: {
56 suffix: "64",
57 },
58 }
59}
60
61libbacktrace_sources = [
62 "Backtrace.cpp",
63 "BacktraceCurrent.cpp",
64 "BacktracePtrace.cpp",
65 "thread_utils.c",
66 "ThreadEntry.cpp",
67 "UnwindCurrent.cpp",
68 "UnwindMap.cpp",
69 "UnwindPtrace.cpp",
70]
71
72cc_library {
73 name: "libbacktrace",
74 defaults: ["libbacktrace_common"],
75 host_supported: true,
76
77 srcs: [
78 "BacktraceMap.cpp",
79 ],
80
81 target: {
82 darwin: {
83 enabled: true,
84 },
85 linux: {
86 srcs: libbacktrace_sources,
87
88 shared_libs: [
89 "libbase",
90 "liblog",
91 "libunwind",
92 ],
93
94 static_libs: ["libcutils"],
Colin Cross53783b12016-10-20 10:39:51 -070095 host_ldlibs: ["-lrt"],
Dan Willemsen2e1591b2016-07-12 17:20:18 -070096 },
97 android: {
98 srcs: libbacktrace_sources,
99
100 shared_libs: [
101 "libbase",
102 "liblog",
103 "libunwind",
104 ],
105
106 static_libs: ["libcutils"],
107 },
108 },
109}
110
111cc_library_shared {
112 name: "libbacktrace_test",
113 defaults: ["libbacktrace_common"],
114 host_supported: true,
115 strip: {
116 none: true,
117 },
118 cflags: ["-O0"],
119 srcs: ["backtrace_testlib.c"],
Yabin Cui5d991bc2016-11-15 17:47:09 -0800120
121 target: {
122 linux: {
123 shared_libs: [
124 "libunwind",
125 ],
126 },
127 android: {
128 shared_libs: [
129 "libunwind",
130 ],
131 },
132 }
Colin Crossda9bd592016-12-14 17:24:46 -0800133}
134
135//-------------------------------------------------------------------------
136// The libbacktrace_offline static library.
137//-------------------------------------------------------------------------
138cc_library_static {
139 name: "libbacktrace_offline",
140 defaults: ["libbacktrace_common"],
141 host_supported: true,
142 srcs: ["BacktraceOffline.cpp"],
143
144 cflags: [
145 "-D__STDC_CONSTANT_MACROS",
146 "-D__STDC_LIMIT_MACROS",
147 "-D__STDC_FORMAT_MACROS",
148 ],
149
150 header_libs: ["llvm-headers"],
151
152 // Use shared libraries so their headers get included during build.
153 shared_libs = [
154 "libbase",
155 "libunwind",
156 ],
157}
158
159//-------------------------------------------------------------------------
160// The backtrace_test executable.
161//-------------------------------------------------------------------------
162cc_test {
163 name: "backtrace_test",
164 defaults: ["libbacktrace_common"],
165 host_supported: true,
166 srcs: [
167 "backtrace_offline_test.cpp",
168 "backtrace_test.cpp",
169 "GetPss.cpp",
170 "thread_utils.c",
171 ],
172
173 cflags: [
174 "-fno-builtin",
175 "-O0",
176 "-g",
177 ],
178
179 shared_libs: [
180 "libbacktrace_test",
181 "libbacktrace",
182 "libbase",
183 "libcutils",
184 "liblog",
185 "libunwind",
186 ],
187
188 group_static_libs: true,
189
190 // Statically link LLVMlibraries to remove dependency on llvm shared library.
191 static_libs = [
192 "libbacktrace_offline",
193 "libLLVMObject",
194 "libLLVMBitReader",
195 "libLLVMMC",
196 "libLLVMMCParser",
197 "libLLVMCore",
198 "libLLVMSupport",
199
200 "libziparchive",
201 "libz",
202 ],
203
204 header_libs: ["llvm-headers"],
205
206 target: {
207 android: {
208 cflags: ["-DENABLE_PSS_TESTS"],
209 shared_libs: [
210 "libdl",
211 "libutils",
212 ],
213 },
214 linux: {
215 host_ldlibs: [
216 "-lpthread",
217 "-lrt",
218 "-ldl",
219 "-lncurses",
220 ],
221 static_libs: ["libutils"],
222 },
223 },
224}