Home | History | Annotate | Download | only in libunwind
      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 
     22 cc_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 
    123 cc_library {
    124     name: "libunwind",
    125     defaults: ["libunwind_defaults"],
    126     vendor_available: false,
    127     vndk: {
    128         enabled: true,
    129         support_system_process: true,
    130     },
    131     sdk_version: "21",
    132     stl: "none",
    133 
    134     srcs: [
    135         "src/mi/init.c",
    136         "src/mi/flush_cache.c",
    137         "src/mi/mempool.c",
    138         "src/mi/strerror.c",
    139         "src/mi/backtrace.c",
    140         "src/mi/dyn-cancel.c",
    141         "src/mi/dyn-info-list.c",
    142         "src/mi/dyn-register.c",
    143         "src/mi/map.c",
    144         "src/mi/Lmap.c",
    145         "src/mi/Ldyn-extract.c",
    146         "src/mi/Lfind_dynamic_proc_info.c",
    147         "src/mi/Lget_proc_info_by_ip.c",
    148         "src/mi/Lget_proc_name.c",
    149         "src/mi/Lput_dynamic_unwind_info.c",
    150         "src/mi/Ldestroy_addr_space.c",
    151         "src/mi/Lget_reg.c",
    152         "src/mi/Lset_reg.c",
    153         "src/mi/Lget_fpreg.c",
    154         "src/mi/Lset_fpreg.c",
    155         "src/mi/Lset_caching_policy.c",
    156         "src/mi/Gdyn-extract.c",
    157         "src/mi/Gdyn-remote.c",
    158         "src/mi/Gfind_dynamic_proc_info.c",
    159         "src/mi/Gget_accessors.c",
    160         "src/mi/Gget_proc_info_by_ip.c",
    161         "src/mi/Gget_proc_name.c",
    162         "src/mi/Gput_dynamic_unwind_info.c",
    163         "src/mi/Gdestroy_addr_space.c",
    164         "src/mi/Gget_reg.c",
    165         "src/mi/Gset_reg.c",
    166         "src/mi/Gget_fpreg.c",
    167         "src/mi/Gset_fpreg.c",
    168         "src/mi/Gset_caching_policy.c",
    169         "src/dwarf/Lexpr.c",
    170         "src/dwarf/Lfde.c",
    171         "src/dwarf/Lparser.c",
    172         "src/dwarf/Lpe.c",
    173         "src/dwarf/Lstep_dwarf.c",
    174         "src/dwarf/Lfind_proc_info-lsb.c",
    175         "src/dwarf/Lfind_unwind_table.c",
    176         "src/dwarf/Gexpr.c",
    177         "src/dwarf/Gfde.c",
    178         "src/dwarf/Gfind_proc_info-lsb.c",
    179         "src/dwarf/Gfind_unwind_table.c",
    180         "src/dwarf/Gparser.c",
    181         "src/dwarf/Gpe.c",
    182         "src/dwarf/Gstep_dwarf.c",
    183         "src/dwarf/global.c",
    184         "src/os-common.c",
    185         "src/os-linux.c",
    186         "src/Los-common.c",
    187 
    188         // ptrace files for remote unwinding.
    189         "src/ptrace/_UPT_accessors.c",
    190         "src/ptrace/_UPT_access_fpreg.c",
    191         "src/ptrace/_UPT_access_mem.c",
    192         "src/ptrace/_UPT_access_reg.c",
    193         "src/ptrace/_UPT_create.c",
    194         "src/ptrace/_UPT_destroy.c",
    195         "src/ptrace/_UPT_find_proc_info.c",
    196         "src/ptrace/_UPT_get_dyn_info_list_addr.c",
    197         "src/ptrace/_UPT_put_unwind_info.c",
    198         "src/ptrace/_UPT_get_proc_name.c",
    199         "src/ptrace/_UPT_reg_offset.c",
    200         "src/ptrace/_UPT_resume.c",
    201     ],
    202 
    203     arch: {
    204         arm: {
    205             srcs: [
    206                 "src/arm/is_fpreg.c",
    207                 "src/arm/regname.c",
    208                 "src/arm/Gcreate_addr_space.c",
    209                 "src/arm/Gget_proc_info.c",
    210                 "src/arm/Gget_save_loc.c",
    211                 "src/arm/Gglobal.c",
    212                 "src/arm/Ginit.c",
    213                 "src/arm/Ginit_local.c",
    214                 "src/arm/Ginit_remote.c",
    215                 "src/arm/Gregs.c",
    216                 "src/arm/Gresume.c",
    217                 "src/arm/Gstep.c",
    218                 "src/arm/Lcreate_addr_space.c",
    219                 "src/arm/Lget_proc_info.c",
    220                 "src/arm/Lget_save_loc.c",
    221                 "src/arm/Lglobal.c",
    222                 "src/arm/Linit.c",
    223                 "src/arm/Linit_local.c",
    224                 "src/arm/Linit_remote.c",
    225                 "src/arm/Lregs.c",
    226                 "src/arm/Lresume.c",
    227                 "src/arm/Lstep.c",
    228 
    229                 "src/arm/getcontext.S",
    230                 "src/arm/Gis_signal_frame.c",
    231                 "src/arm/Gex_tables.c",
    232                 "src/arm/Lis_signal_frame.c",
    233                 "src/arm/Lex_tables.c",
    234             ],
    235         },
    236         arm64: {
    237             srcs: [
    238                 "src/aarch64/is_fpreg.c",
    239                 "src/aarch64/regname.c",
    240                 "src/aarch64/Gcreate_addr_space.c",
    241                 "src/aarch64/Gget_proc_info.c",
    242                 "src/aarch64/Gget_save_loc.c",
    243                 "src/aarch64/Gglobal.c",
    244                 "src/aarch64/Ginit.c",
    245                 "src/aarch64/Ginit_local.c",
    246                 "src/aarch64/Ginit_remote.c",
    247                 "src/aarch64/Gregs.c",
    248                 "src/aarch64/Gresume.c",
    249                 "src/aarch64/Gstep.c",
    250                 "src/aarch64/Lcreate_addr_space.c",
    251                 "src/aarch64/Lget_proc_info.c",
    252                 "src/aarch64/Lget_save_loc.c",
    253                 "src/aarch64/Lglobal.c",
    254                 "src/aarch64/Linit.c",
    255                 "src/aarch64/Linit_local.c",
    256                 "src/aarch64/Linit_remote.c",
    257                 "src/aarch64/Lregs.c",
    258                 "src/aarch64/Lresume.c",
    259                 "src/aarch64/Lstep.c",
    260 
    261                 "src/aarch64/Gis_signal_frame.c",
    262                 "src/aarch64/Lis_signal_frame.c",
    263             ],
    264         },
    265         mips: {
    266             srcs: [
    267                 "src/mips/is_fpreg.c",
    268                 "src/mips/regname.c",
    269                 "src/mips/Gcreate_addr_space.c",
    270                 "src/mips/Gget_proc_info.c",
    271                 "src/mips/Gget_save_loc.c",
    272                 "src/mips/Gglobal.c",
    273                 "src/mips/Ginit.c",
    274                 "src/mips/Ginit_local.c",
    275                 "src/mips/Ginit_remote.c",
    276                 "src/mips/Gregs.c",
    277                 "src/mips/Gresume.c",
    278                 "src/mips/Gstep.c",
    279                 "src/mips/Lcreate_addr_space.c",
    280                 "src/mips/Lget_proc_info.c",
    281                 "src/mips/Lget_save_loc.c",
    282                 "src/mips/Lglobal.c",
    283                 "src/mips/Linit.c",
    284                 "src/mips/Linit_local.c",
    285                 "src/mips/Linit_remote.c",
    286                 "src/mips/Lregs.c",
    287                 "src/mips/Lresume.c",
    288                 "src/mips/Lstep.c",
    289 
    290                 "src/mips/getcontext-android.S",
    291                 "src/mips/Gis_signal_frame.c",
    292                 "src/mips/Lis_signal_frame.c",
    293             ],
    294         },
    295         // mips and mips64 use the same sources but define _MIP_SIM differently
    296         // to change the behavior.
    297         //   mips uses o32 abi (_MIPS_SIM == _ABIO32).
    298         //   mips64 uses n64 abi (_MIPS_SIM == _ABI64).
    299         mips64: {
    300             srcs: [
    301                 "src/mips/is_fpreg.c",
    302                 "src/mips/regname.c",
    303                 "src/mips/Gcreate_addr_space.c",
    304                 "src/mips/Gget_proc_info.c",
    305                 "src/mips/Gget_save_loc.c",
    306                 "src/mips/Gglobal.c",
    307                 "src/mips/Ginit.c",
    308                 "src/mips/Ginit_local.c",
    309                 "src/mips/Ginit_remote.c",
    310                 "src/mips/Gregs.c",
    311                 "src/mips/Gresume.c",
    312                 "src/mips/Gstep.c",
    313                 "src/mips/Lcreate_addr_space.c",
    314                 "src/mips/Lget_proc_info.c",
    315                 "src/mips/Lget_save_loc.c",
    316                 "src/mips/Lglobal.c",
    317                 "src/mips/Linit.c",
    318                 "src/mips/Linit_local.c",
    319                 "src/mips/Linit_remote.c",
    320                 "src/mips/Lregs.c",
    321                 "src/mips/Lresume.c",
    322                 "src/mips/Lstep.c",
    323 
    324                 "src/mips/getcontext-android.S",
    325                 "src/mips/Gis_signal_frame.c",
    326                 "src/mips/Lis_signal_frame.c",
    327             ],
    328         },
    329         x86: {
    330             srcs: [
    331                 "src/x86/is_fpreg.c",
    332                 "src/x86/regname.c",
    333                 "src/x86/Gcreate_addr_space.c",
    334                 "src/x86/Gget_proc_info.c",
    335                 "src/x86/Gget_save_loc.c",
    336                 "src/x86/Gglobal.c",
    337                 "src/x86/Ginit.c",
    338                 "src/x86/Ginit_local.c",
    339                 "src/x86/Ginit_remote.c",
    340                 "src/x86/Gregs.c",
    341                 "src/x86/Gresume.c",
    342                 "src/x86/Gstep.c",
    343                 "src/x86/Lcreate_addr_space.c",
    344                 "src/x86/Lget_proc_info.c",
    345                 "src/x86/Lget_save_loc.c",
    346                 "src/x86/Lglobal.c",
    347                 "src/x86/Linit.c",
    348                 "src/x86/Linit_local.c",
    349                 "src/x86/Linit_remote.c",
    350                 "src/x86/Lregs.c",
    351                 "src/x86/Lresume.c",
    352                 "src/x86/Lstep.c",
    353 
    354                 "src/x86/getcontext-linux.S",
    355                 "src/x86/Gos-linux.c",
    356                 "src/x86/Los-linux.c",
    357             ],
    358         },
    359         x86_64: {
    360             srcs: [
    361                 "src/x86_64/is_fpreg.c",
    362                 "src/x86_64/regname.c",
    363                 "src/x86_64/Gcreate_addr_space.c",
    364                 "src/x86_64/Gget_proc_info.c",
    365                 "src/x86_64/Gget_save_loc.c",
    366                 "src/x86_64/Gglobal.c",
    367                 "src/x86_64/Ginit.c",
    368                 "src/x86_64/Ginit_local.c",
    369                 "src/x86_64/Ginit_remote.c",
    370                 "src/x86_64/Gregs.c",
    371                 "src/x86_64/Gresume.c",
    372                 "src/x86_64/Gstep.c",
    373                 "src/x86_64/Lcreate_addr_space.c",
    374                 "src/x86_64/Lget_proc_info.c",
    375                 "src/x86_64/Lget_save_loc.c",
    376                 "src/x86_64/Lglobal.c",
    377                 "src/x86_64/Linit.c",
    378                 "src/x86_64/Linit_local.c",
    379                 "src/x86_64/Linit_remote.c",
    380                 "src/x86_64/Lregs.c",
    381                 "src/x86_64/Lresume.c",
    382                 "src/x86_64/Lstep.c",
    383 
    384                 "src/x86_64/getcontext.S",
    385                 "src/x86_64/Gstash_frame.c",
    386                 "src/x86_64/Gtrace.c",
    387                 "src/x86_64/Gos-linux.c",
    388                 "src/x86_64/Lstash_frame.c",
    389                 "src/x86_64/Ltrace.c",
    390                 "src/x86_64/Los-linux.c",
    391                 "src/x86_64/setcontext.S",
    392             ],
    393         },
    394     },
    395 
    396     multilib: {
    397         lib32: {
    398             srcs: ["src/elf32.c"],
    399         },
    400         lib64: {
    401             srcs: ["src/elf64.c"],
    402         },
    403     },
    404 
    405     target: {
    406         linux_glibc: {
    407             // Remove dependencies on libgcc
    408             ldflags: ["-nostdlib"],
    409         },
    410         linux_bionic: {
    411             enabled: true,
    412         },
    413     },
    414 
    415     export_include_dirs: ["include"],
    416 
    417     shared_libs: ["liblzma"],
    418 
    419     debug: {
    420         //shared_libs: ["liblog"],
    421     },
    422 }
    423 
    424 //-----------------------------------------------------------------------
    425 // libunwindbacktrace static library
    426 //-----------------------------------------------------------------------
    427 cc_library_static {
    428     name: "libunwindbacktrace",
    429     defaults: ["libunwind_defaults"],
    430     vendor_available: true,
    431     sdk_version: "21",
    432     srcs: [
    433         "src/unwind/BacktraceWrapper.c",
    434         "src/unwind/DeleteException.c",
    435         "src/unwind/FindEnclosingFunction.c",
    436         "src/unwind/ForcedUnwind.c",
    437         "src/unwind/GetBSP.c",
    438         "src/unwind/GetCFA.c",
    439         "src/unwind/GetDataRelBase.c",
    440         "src/unwind/GetGR.c",
    441         "src/unwind/GetIP.c",
    442         "src/unwind/GetIPInfo.c",
    443         "src/unwind/GetLanguageSpecificData.c",
    444         "src/unwind/GetRegionStart.c",
    445         "src/unwind/GetTextRelBase.c",
    446         "src/unwind/RaiseException.c",
    447         "src/unwind/Resume.c",
    448         "src/unwind/Resume_or_Rethrow.c",
    449         "src/unwind/SetGR.c",
    450         "src/unwind/SetIP.c",
    451     ],
    452 
    453     cflags: [
    454         "-Wno-old-style-declaration",
    455         "-fvisibility=hidden",
    456     ],
    457 
    458     target: {
    459         linux_bionic: {
    460             enabled: true,
    461         },
    462     },
    463 }
    464 
    465 //-----------------------------------------------------------------------
    466 // libunwind testing
    467 //-----------------------------------------------------------------------
    468 cc_test {
    469     name: "libunwind-unit-tests",
    470     srcs: ["android/tests/local_test.cpp"],
    471     defaults: ["libunwind_defaults"],
    472 
    473     cflags: [
    474         "-fno-builtin",
    475         "-O0",
    476         "-g",
    477     ],
    478 
    479     local_include_dirs: ["include"],
    480     shared_libs: ["libunwind"],
    481 }
    482 
    483 /*
    484 // Run the unit tests built for x86 or x86_64.
    485 // ANDROIDMK TRANSLATION ERROR: unsupported conditional
    486 // ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
    487 // ANDROIDMK TRANSLATION ERROR: unsupported conditional
    488 // ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86))
    489 LINKER = ["linker64"]
    490 TEST_SUFFIX = ["64"]
    491 // ANDROIDMK TRANSLATION ERROR: else from unsupported contitional
    492 // else
    493 LINKER = ["linker"]
    494 TEST_SUFFIX = ["32"]
    495 // ANDROIDMK TRANSLATION ERROR: endif from unsupported contitional
    496 // endif
    497 
    498 // ANDROIDMK TRANSLATION ERROR: endif from unsupported contitional
    499 // endif
    500 */
    501