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