• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
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
17// Set to true to enable a debug build of the libraries.
18// To control what is logged, set the environment variable UNW_DEBUG_LEVEL=x,
19// where x controls the verbosity (from 1 to 20).
20//libunwind_debug = false
21
22cc_defaults {
23    name: "libunwind_defaults",
24    host_supported: true,
25
26    cppflags: [
27        "-Wno-old-style-cast",
28    ],
29
30    cflags: [
31        "-Werror",
32        "-Wno-#pragma-messages",
33        "-Wno-unused-parameter",
34
35        "-DHAVE_CONFIG_H",
36        "-D_GNU_SOURCE",
37        "-DNDEBUG",
38    ],
39
40    // libunwind expects to find include/libunwind_i.h before
41    // include/tdep-<arch>/libunwind_i.h, but soong prepends arch-specific
42    // include directories.  To keep the include directories in the right
43    // order, pass "include" as an architecture specific include for every
44    // architecture.
45    arch: {
46        arm: {
47            local_include_dirs: [
48                "include",
49                "include/tdep-arm",
50            ],
51        },
52        arm64: {
53            local_include_dirs: [
54                "include",
55                "include/tdep-aarch64",
56            ],
57        },
58        mips: {
59            local_include_dirs: [
60                "include",
61                "include/tdep-mips",
62            ],
63        },
64        mips64: {
65            local_include_dirs: [
66                "include",
67                "include/tdep-mips",
68            ],
69        },
70        x86: {
71            local_include_dirs: [
72                "include",
73                "include/tdep-x86",
74            ],
75        },
76        x86_64: {
77            local_include_dirs: [
78                "include",
79                "include/tdep-x86_64",
80            ],
81        },
82    },
83
84    target: {
85        android: {
86            // gcc 4.8 appears to be overeager declaring that a variable is uninitialized,
87            // under certain circumstances. Turn off this warning only for target so that
88            // coverage is still present for the host code. When the entire build system
89            // is switched to 4.9, then this can be removed.
90            cflags: ["-Wno-maybe-uninitialized"],
91        },
92        darwin: {
93            enabled: false,
94        },
95    },
96
97    clang_cflags: [
98        // src/mi/backtrace.c is misdetected as a bogus header guard by clang 3.5
99        // src/x86_64/Gstash_frame.c has unnecessary calls to labs.
100        "-Wno-header-guard",
101        "-Wno-absolute-value",
102        // The latest clang (r230699) does not allow SP/PC to be declared in inline asm lists.
103        "-Wno-inline-asm",
104    ],
105
106    debug: {
107        cflags: [
108            "-UNDEBUG",
109            "-DDEBUG",
110            "-U_FORTIFY_SOURCE",
111        ],
112    },
113
114    local_include_dirs: [
115        "src",
116    ],
117}
118
119//-----------------------------------------------------------------------
120// libunwind shared and static library
121//-----------------------------------------------------------------------
122
123cc_defaults {
124    name: "libunwind_core_defaults",
125    defaults: ["libunwind_defaults"],
126    sdk_version: "21",
127    stl: "none",
128
129    srcs: [
130        "src/mi/init.c",
131        "src/mi/flush_cache.c",
132        "src/mi/mempool.c",
133        "src/mi/strerror.c",
134        "src/mi/backtrace.c",
135        "src/mi/dyn-cancel.c",
136        "src/mi/dyn-info-list.c",
137        "src/mi/dyn-register.c",
138        "src/mi/map.c",
139        "src/mi/Lmap.c",
140        "src/mi/Ldyn-extract.c",
141        "src/mi/Lfind_dynamic_proc_info.c",
142        "src/mi/Lget_proc_info_by_ip.c",
143        "src/mi/Lget_proc_name.c",
144        "src/mi/Lput_dynamic_unwind_info.c",
145        "src/mi/Ldestroy_addr_space.c",
146        "src/mi/Lget_reg.c",
147        "src/mi/Lset_reg.c",
148        "src/mi/Lget_fpreg.c",
149        "src/mi/Lset_fpreg.c",
150        "src/mi/Lset_caching_policy.c",
151        "src/mi/Gdyn-extract.c",
152        "src/mi/Gdyn-remote.c",
153        "src/mi/Gfind_dynamic_proc_info.c",
154        "src/mi/Gget_accessors.c",
155        "src/mi/Gget_proc_info_by_ip.c",
156        "src/mi/Gget_proc_name.c",
157        "src/mi/Gput_dynamic_unwind_info.c",
158        "src/mi/Gdestroy_addr_space.c",
159        "src/mi/Gget_reg.c",
160        "src/mi/Gset_reg.c",
161        "src/mi/Gget_fpreg.c",
162        "src/mi/Gset_fpreg.c",
163        "src/mi/Gset_caching_policy.c",
164        "src/dwarf/Lexpr.c",
165        "src/dwarf/Lfde.c",
166        "src/dwarf/Lparser.c",
167        "src/dwarf/Lpe.c",
168        "src/dwarf/Lstep_dwarf.c",
169        "src/dwarf/Lfind_proc_info-lsb.c",
170        "src/dwarf/Lfind_unwind_table.c",
171        "src/dwarf/Gexpr.c",
172        "src/dwarf/Gfde.c",
173        "src/dwarf/Gfind_proc_info-lsb.c",
174        "src/dwarf/Gfind_unwind_table.c",
175        "src/dwarf/Gparser.c",
176        "src/dwarf/Gpe.c",
177        "src/dwarf/Gstep_dwarf.c",
178        "src/dwarf/global.c",
179        "src/os-common.c",
180        "src/os-linux.c",
181        "src/Los-common.c",
182
183        // ptrace files for remote unwinding.
184        "src/ptrace/_UPT_accessors.c",
185        "src/ptrace/_UPT_access_fpreg.c",
186        "src/ptrace/_UPT_access_mem.c",
187        "src/ptrace/_UPT_access_reg.c",
188        "src/ptrace/_UPT_create.c",
189        "src/ptrace/_UPT_destroy.c",
190        "src/ptrace/_UPT_find_proc_info.c",
191        "src/ptrace/_UPT_get_dyn_info_list_addr.c",
192        "src/ptrace/_UPT_put_unwind_info.c",
193        "src/ptrace/_UPT_get_proc_name.c",
194        "src/ptrace/_UPT_reg_offset.c",
195        "src/ptrace/_UPT_resume.c",
196    ],
197
198    arch: {
199        arm: {
200            srcs: [
201                "src/arm/is_fpreg.c",
202                "src/arm/regname.c",
203                "src/arm/Gcreate_addr_space.c",
204                "src/arm/Gget_proc_info.c",
205                "src/arm/Gget_save_loc.c",
206                "src/arm/Gglobal.c",
207                "src/arm/Ginit.c",
208                "src/arm/Ginit_local.c",
209                "src/arm/Ginit_remote.c",
210                "src/arm/Gregs.c",
211                "src/arm/Gresume.c",
212                "src/arm/Gstep.c",
213                "src/arm/Lcreate_addr_space.c",
214                "src/arm/Lget_proc_info.c",
215                "src/arm/Lget_save_loc.c",
216                "src/arm/Lglobal.c",
217                "src/arm/Linit.c",
218                "src/arm/Linit_local.c",
219                "src/arm/Linit_remote.c",
220                "src/arm/Lregs.c",
221                "src/arm/Lresume.c",
222                "src/arm/Lstep.c",
223
224                "src/arm/getcontext.S",
225                "src/arm/Gis_signal_frame.c",
226                "src/arm/Gex_tables.c",
227                "src/arm/Lis_signal_frame.c",
228                "src/arm/Lex_tables.c",
229            ],
230        },
231        arm64: {
232            srcs: [
233                "src/aarch64/is_fpreg.c",
234                "src/aarch64/regname.c",
235                "src/aarch64/Gcreate_addr_space.c",
236                "src/aarch64/Gget_proc_info.c",
237                "src/aarch64/Gget_save_loc.c",
238                "src/aarch64/Gglobal.c",
239                "src/aarch64/Ginit.c",
240                "src/aarch64/Ginit_local.c",
241                "src/aarch64/Ginit_remote.c",
242                "src/aarch64/Gregs.c",
243                "src/aarch64/Gresume.c",
244                "src/aarch64/Gstep.c",
245                "src/aarch64/Lcreate_addr_space.c",
246                "src/aarch64/Lget_proc_info.c",
247                "src/aarch64/Lget_save_loc.c",
248                "src/aarch64/Lglobal.c",
249                "src/aarch64/Linit.c",
250                "src/aarch64/Linit_local.c",
251                "src/aarch64/Linit_remote.c",
252                "src/aarch64/Lregs.c",
253                "src/aarch64/Lresume.c",
254                "src/aarch64/Lstep.c",
255
256                "src/aarch64/Gis_signal_frame.c",
257                "src/aarch64/Lis_signal_frame.c",
258            ],
259        },
260        mips: {
261            srcs: [
262                "src/mips/is_fpreg.c",
263                "src/mips/regname.c",
264                "src/mips/Gcreate_addr_space.c",
265                "src/mips/Gget_proc_info.c",
266                "src/mips/Gget_save_loc.c",
267                "src/mips/Gglobal.c",
268                "src/mips/Ginit.c",
269                "src/mips/Ginit_local.c",
270                "src/mips/Ginit_remote.c",
271                "src/mips/Gregs.c",
272                "src/mips/Gresume.c",
273                "src/mips/Gstep.c",
274                "src/mips/Lcreate_addr_space.c",
275                "src/mips/Lget_proc_info.c",
276                "src/mips/Lget_save_loc.c",
277                "src/mips/Lglobal.c",
278                "src/mips/Linit.c",
279                "src/mips/Linit_local.c",
280                "src/mips/Linit_remote.c",
281                "src/mips/Lregs.c",
282                "src/mips/Lresume.c",
283                "src/mips/Lstep.c",
284
285                "src/mips/getcontext-android.S",
286                "src/mips/Gis_signal_frame.c",
287                "src/mips/Lis_signal_frame.c",
288            ],
289        },
290        // mips and mips64 use the same sources but define _MIP_SIM differently
291        // to change the behavior.
292        //   mips uses o32 abi (_MIPS_SIM == _ABIO32).
293        //   mips64 uses n64 abi (_MIPS_SIM == _ABI64).
294        mips64: {
295            srcs: [
296                "src/mips/is_fpreg.c",
297                "src/mips/regname.c",
298                "src/mips/Gcreate_addr_space.c",
299                "src/mips/Gget_proc_info.c",
300                "src/mips/Gget_save_loc.c",
301                "src/mips/Gglobal.c",
302                "src/mips/Ginit.c",
303                "src/mips/Ginit_local.c",
304                "src/mips/Ginit_remote.c",
305                "src/mips/Gregs.c",
306                "src/mips/Gresume.c",
307                "src/mips/Gstep.c",
308                "src/mips/Lcreate_addr_space.c",
309                "src/mips/Lget_proc_info.c",
310                "src/mips/Lget_save_loc.c",
311                "src/mips/Lglobal.c",
312                "src/mips/Linit.c",
313                "src/mips/Linit_local.c",
314                "src/mips/Linit_remote.c",
315                "src/mips/Lregs.c",
316                "src/mips/Lresume.c",
317                "src/mips/Lstep.c",
318
319                "src/mips/getcontext-android.S",
320                "src/mips/Gis_signal_frame.c",
321                "src/mips/Lis_signal_frame.c",
322            ],
323        },
324        x86: {
325            srcs: [
326                "src/x86/is_fpreg.c",
327                "src/x86/regname.c",
328                "src/x86/Gcreate_addr_space.c",
329                "src/x86/Gget_proc_info.c",
330                "src/x86/Gget_save_loc.c",
331                "src/x86/Gglobal.c",
332                "src/x86/Ginit.c",
333                "src/x86/Ginit_local.c",
334                "src/x86/Ginit_remote.c",
335                "src/x86/Gregs.c",
336                "src/x86/Gresume.c",
337                "src/x86/Gstep.c",
338                "src/x86/Lcreate_addr_space.c",
339                "src/x86/Lget_proc_info.c",
340                "src/x86/Lget_save_loc.c",
341                "src/x86/Lglobal.c",
342                "src/x86/Linit.c",
343                "src/x86/Linit_local.c",
344                "src/x86/Linit_remote.c",
345                "src/x86/Lregs.c",
346                "src/x86/Lresume.c",
347                "src/x86/Lstep.c",
348
349                "src/x86/getcontext-linux.S",
350                "src/x86/Gos-linux.c",
351                "src/x86/Los-linux.c",
352            ],
353        },
354        x86_64: {
355            srcs: [
356                "src/x86_64/is_fpreg.c",
357                "src/x86_64/regname.c",
358                "src/x86_64/Gcreate_addr_space.c",
359                "src/x86_64/Gget_proc_info.c",
360                "src/x86_64/Gget_save_loc.c",
361                "src/x86_64/Gglobal.c",
362                "src/x86_64/Ginit.c",
363                "src/x86_64/Ginit_local.c",
364                "src/x86_64/Ginit_remote.c",
365                "src/x86_64/Gregs.c",
366                "src/x86_64/Gresume.c",
367                "src/x86_64/Gstep.c",
368                "src/x86_64/Lcreate_addr_space.c",
369                "src/x86_64/Lget_proc_info.c",
370                "src/x86_64/Lget_save_loc.c",
371                "src/x86_64/Lglobal.c",
372                "src/x86_64/Linit.c",
373                "src/x86_64/Linit_local.c",
374                "src/x86_64/Linit_remote.c",
375                "src/x86_64/Lregs.c",
376                "src/x86_64/Lresume.c",
377                "src/x86_64/Lstep.c",
378
379                "src/x86_64/getcontext.S",
380                "src/x86_64/Gstash_frame.c",
381                "src/x86_64/Gtrace.c",
382                "src/x86_64/Gos-linux.c",
383                "src/x86_64/Lstash_frame.c",
384                "src/x86_64/Ltrace.c",
385                "src/x86_64/Los-linux.c",
386                "src/x86_64/setcontext.S",
387            ],
388        },
389    },
390
391    multilib: {
392        lib32: {
393            srcs: ["src/elf32.c"],
394        },
395        lib64: {
396            srcs: ["src/elf64.c"],
397        },
398    },
399
400    target: {
401        linux_bionic: {
402            enabled: true,
403        },
404    },
405
406    export_include_dirs: ["include"],
407
408    debug: {
409        //shared_libs: ["liblog"],
410    },
411}
412
413cc_library_shared {
414    name: "libunwind",
415    defaults: ["libunwind_core_defaults"],
416}
417
418cc_library_static {
419    name: "libunwind_static",
420    defaults: ["libunwind_core_defaults"],
421    vendor_available: true,
422    native_bridge_supported: true,
423}
424
425//-----------------------------------------------------------------------
426// libunwindbacktrace static library
427//-----------------------------------------------------------------------
428cc_library_static {
429    name: "libunwindbacktrace",
430    defaults: ["libunwind_defaults"],
431    vendor_available: true,
432    native_bridge_supported: true,
433    sdk_version: "21",
434    srcs: [
435        "src/unwind/BacktraceWrapper.c",
436        "src/unwind/DeleteException.c",
437        "src/unwind/FindEnclosingFunction.c",
438        "src/unwind/ForcedUnwind.c",
439        "src/unwind/GetBSP.c",
440        "src/unwind/GetCFA.c",
441        "src/unwind/GetDataRelBase.c",
442        "src/unwind/GetGR.c",
443        "src/unwind/GetIP.c",
444        "src/unwind/GetIPInfo.c",
445        "src/unwind/GetLanguageSpecificData.c",
446        "src/unwind/GetRegionStart.c",
447        "src/unwind/GetTextRelBase.c",
448        "src/unwind/RaiseException.c",
449        "src/unwind/Resume.c",
450        "src/unwind/Resume_or_Rethrow.c",
451        "src/unwind/SetGR.c",
452        "src/unwind/SetIP.c",
453    ],
454
455    cflags: [
456        "-Wno-old-style-declaration",
457        "-fvisibility=hidden",
458    ],
459
460    target: {
461        linux_bionic: {
462            enabled: true,
463        },
464    },
465}
466
467//-----------------------------------------------------------------------
468// libunwind testing
469//-----------------------------------------------------------------------
470cc_test {
471    name: "libunwind-unit-tests",
472    srcs: ["android/tests/local_test.cpp"],
473    defaults: ["libunwind_defaults"],
474
475    cflags: [
476        "-fno-builtin",
477        "-O0",
478        "-g",
479    ],
480
481    local_include_dirs: ["include"],
482    shared_libs: ["libunwind"],
483}
484
485/*
486// Run the unit tests built for x86 or x86_64.
487// ANDROIDMK TRANSLATION ERROR: unsupported conditional
488// ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
489// ANDROIDMK TRANSLATION ERROR: unsupported conditional
490// ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86))
491LINKER = ["linker64"]
492TEST_SUFFIX = ["64"]
493// ANDROIDMK TRANSLATION ERROR: else from unsupported contitional
494// else
495LINKER = ["linker"]
496TEST_SUFFIX = ["32"]
497// ANDROIDMK TRANSLATION ERROR: endif from unsupported contitional
498// endif
499
500// ANDROIDMK TRANSLATION ERROR: endif from unsupported contitional
501// endif
502*/
503