1# 2# Copyright 2017 The Abseil Authors. 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# https://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 17load( 18 "//absl:copts/configure_copts.bzl", 19 "ABSL_DEFAULT_COPTS", 20 "ABSL_DEFAULT_LINKOPTS", 21 "ABSL_TEST_COPTS", 22) 23 24package(default_visibility = ["//visibility:public"]) 25 26licenses(["notice"]) 27 28cc_library( 29 name = "atomic_hook", 30 hdrs = ["internal/atomic_hook.h"], 31 copts = ABSL_DEFAULT_COPTS, 32 linkopts = ABSL_DEFAULT_LINKOPTS, 33 visibility = [ 34 "//absl:__subpackages__", 35 ], 36 deps = [ 37 ":config", 38 ":core_headers", 39 ], 40) 41 42cc_library( 43 name = "errno_saver", 44 hdrs = ["internal/errno_saver.h"], 45 copts = ABSL_DEFAULT_COPTS, 46 linkopts = ABSL_DEFAULT_LINKOPTS, 47 visibility = [ 48 "//absl:__subpackages__", 49 ], 50 deps = [":config"], 51) 52 53cc_library( 54 name = "log_severity", 55 srcs = ["log_severity.cc"], 56 hdrs = ["log_severity.h"], 57 copts = ABSL_DEFAULT_COPTS, 58 linkopts = ABSL_DEFAULT_LINKOPTS, 59 deps = [ 60 ":config", 61 ":core_headers", 62 ], 63) 64 65cc_library( 66 name = "raw_logging_internal", 67 srcs = ["internal/raw_logging.cc"], 68 hdrs = ["internal/raw_logging.h"], 69 copts = ABSL_DEFAULT_COPTS, 70 linkopts = ABSL_DEFAULT_LINKOPTS, 71 visibility = [ 72 "//absl:__subpackages__", 73 ], 74 deps = [ 75 ":atomic_hook", 76 ":config", 77 ":core_headers", 78 ":errno_saver", 79 ":log_severity", 80 ], 81) 82 83cc_library( 84 name = "spinlock_wait", 85 srcs = [ 86 "internal/spinlock_akaros.inc", 87 "internal/spinlock_linux.inc", 88 "internal/spinlock_posix.inc", 89 "internal/spinlock_wait.cc", 90 "internal/spinlock_win32.inc", 91 ], 92 hdrs = ["internal/spinlock_wait.h"], 93 copts = ABSL_DEFAULT_COPTS, 94 linkopts = ABSL_DEFAULT_LINKOPTS, 95 visibility = [ 96 "//absl/base:__pkg__", 97 ], 98 deps = [ 99 ":base_internal", 100 ":core_headers", 101 ":errno_saver", 102 ], 103) 104 105cc_library( 106 name = "config", 107 hdrs = [ 108 "config.h", 109 "options.h", 110 "policy_checks.h", 111 ], 112 copts = ABSL_DEFAULT_COPTS, 113 linkopts = ABSL_DEFAULT_LINKOPTS, 114) 115 116cc_library( 117 name = "cycleclock_internal", 118 hdrs = [ 119 "internal/cycleclock_config.h", 120 "internal/unscaledcycleclock_config.h", 121 ], 122 copts = ABSL_DEFAULT_COPTS, 123 linkopts = ABSL_DEFAULT_LINKOPTS, 124 visibility = [ 125 "//absl:__subpackages__", 126 ], 127 deps = [ 128 ":base_internal", 129 ":config", 130 ], 131) 132 133cc_library( 134 name = "dynamic_annotations", 135 srcs = [ 136 "internal/dynamic_annotations.h", 137 ], 138 hdrs = [ 139 "dynamic_annotations.h", 140 ], 141 copts = ABSL_DEFAULT_COPTS, 142 linkopts = ABSL_DEFAULT_LINKOPTS, 143 deps = [ 144 ":config", 145 ":core_headers", 146 ], 147) 148 149cc_library( 150 name = "core_headers", 151 srcs = [ 152 "internal/thread_annotations.h", 153 ], 154 hdrs = [ 155 "attributes.h", 156 "const_init.h", 157 "macros.h", 158 "optimization.h", 159 "port.h", 160 "thread_annotations.h", 161 ], 162 copts = ABSL_DEFAULT_COPTS, 163 linkopts = ABSL_DEFAULT_LINKOPTS, 164 deps = [ 165 ":config", 166 ], 167) 168 169cc_library( 170 name = "malloc_internal", 171 srcs = [ 172 "internal/low_level_alloc.cc", 173 ], 174 hdrs = [ 175 "internal/direct_mmap.h", 176 "internal/low_level_alloc.h", 177 ], 178 copts = ABSL_DEFAULT_COPTS + select({ 179 "//conditions:default": [], 180 }), 181 linkopts = select({ 182 "//absl:msvc_compiler": [], 183 "//absl:clang-cl_compiler": [], 184 "//absl:wasm": [], 185 "//conditions:default": ["-pthread"], 186 }) + ABSL_DEFAULT_LINKOPTS, 187 visibility = [ 188 "//visibility:public", 189 ], 190 deps = [ 191 ":base", 192 ":base_internal", 193 ":config", 194 ":core_headers", 195 ":dynamic_annotations", 196 ":raw_logging_internal", 197 ], 198) 199 200cc_library( 201 name = "base_internal", 202 hdrs = [ 203 "internal/hide_ptr.h", 204 "internal/identity.h", 205 "internal/inline_variable.h", 206 "internal/invoke.h", 207 "internal/scheduling_mode.h", 208 ], 209 copts = ABSL_DEFAULT_COPTS, 210 linkopts = ABSL_DEFAULT_LINKOPTS, 211 visibility = [ 212 "//absl:__subpackages__", 213 ], 214 deps = [ 215 ":config", 216 "//absl/meta:type_traits", 217 ], 218) 219 220cc_library( 221 name = "base", 222 srcs = [ 223 "internal/cycleclock.cc", 224 "internal/spinlock.cc", 225 "internal/sysinfo.cc", 226 "internal/thread_identity.cc", 227 "internal/unscaledcycleclock.cc", 228 ], 229 hdrs = [ 230 "call_once.h", 231 "casts.h", 232 "internal/cycleclock.h", 233 "internal/low_level_scheduling.h", 234 "internal/per_thread_tls.h", 235 "internal/spinlock.h", 236 "internal/sysinfo.h", 237 "internal/thread_identity.h", 238 "internal/tsan_mutex_interface.h", 239 "internal/unscaledcycleclock.h", 240 ], 241 copts = ABSL_DEFAULT_COPTS, 242 linkopts = select({ 243 "//absl:msvc_compiler": [ 244 "-DEFAULTLIB:advapi32.lib", 245 ], 246 "//absl:clang-cl_compiler": [ 247 "-DEFAULTLIB:advapi32.lib", 248 ], 249 "//absl:wasm": [], 250 "//conditions:default": ["-pthread"], 251 }) + ABSL_DEFAULT_LINKOPTS, 252 deps = [ 253 ":atomic_hook", 254 ":base_internal", 255 ":config", 256 ":core_headers", 257 ":cycleclock_internal", 258 ":dynamic_annotations", 259 ":log_severity", 260 ":raw_logging_internal", 261 ":spinlock_wait", 262 "//absl/meta:type_traits", 263 ], 264) 265 266cc_library( 267 name = "atomic_hook_test_helper", 268 testonly = 1, 269 srcs = ["internal/atomic_hook_test_helper.cc"], 270 hdrs = ["internal/atomic_hook_test_helper.h"], 271 copts = ABSL_DEFAULT_COPTS, 272 linkopts = ABSL_DEFAULT_LINKOPTS, 273 deps = [ 274 ":atomic_hook", 275 ":core_headers", 276 ], 277) 278 279cc_test( 280 name = "atomic_hook_test", 281 size = "small", 282 srcs = ["internal/atomic_hook_test.cc"], 283 copts = ABSL_TEST_COPTS, 284 linkopts = ABSL_DEFAULT_LINKOPTS, 285 deps = [ 286 ":atomic_hook", 287 ":atomic_hook_test_helper", 288 ":core_headers", 289 "@com_google_googletest//:gtest_main", 290 ], 291) 292 293cc_test( 294 name = "bit_cast_test", 295 size = "small", 296 srcs = [ 297 "bit_cast_test.cc", 298 ], 299 copts = ABSL_TEST_COPTS, 300 linkopts = ABSL_DEFAULT_LINKOPTS, 301 deps = [ 302 ":base", 303 ":core_headers", 304 "@com_google_googletest//:gtest_main", 305 ], 306) 307 308cc_library( 309 name = "throw_delegate", 310 srcs = ["internal/throw_delegate.cc"], 311 hdrs = ["internal/throw_delegate.h"], 312 copts = ABSL_DEFAULT_COPTS, 313 linkopts = ABSL_DEFAULT_LINKOPTS, 314 visibility = [ 315 "//absl:__subpackages__", 316 ], 317 deps = [ 318 ":config", 319 ":raw_logging_internal", 320 ], 321) 322 323cc_test( 324 name = "throw_delegate_test", 325 srcs = ["throw_delegate_test.cc"], 326 copts = ABSL_TEST_COPTS, 327 linkopts = ABSL_DEFAULT_LINKOPTS, 328 deps = [ 329 ":config", 330 ":throw_delegate", 331 "@com_google_googletest//:gtest_main", 332 ], 333) 334 335cc_test( 336 name = "errno_saver_test", 337 size = "small", 338 srcs = ["internal/errno_saver_test.cc"], 339 copts = ABSL_TEST_COPTS, 340 linkopts = ABSL_DEFAULT_LINKOPTS, 341 deps = [ 342 ":errno_saver", 343 ":strerror", 344 "@com_google_googletest//:gtest_main", 345 ], 346) 347 348cc_library( 349 name = "exception_testing", 350 testonly = 1, 351 hdrs = ["internal/exception_testing.h"], 352 copts = ABSL_TEST_COPTS, 353 linkopts = ABSL_DEFAULT_LINKOPTS, 354 visibility = [ 355 "//absl:__subpackages__", 356 ], 357 deps = [ 358 ":config", 359 "@com_google_googletest//:gtest", 360 ], 361) 362 363cc_library( 364 name = "pretty_function", 365 hdrs = ["internal/pretty_function.h"], 366 linkopts = ABSL_DEFAULT_LINKOPTS, 367 visibility = ["//absl:__subpackages__"], 368) 369 370cc_library( 371 name = "exception_safety_testing", 372 testonly = 1, 373 srcs = ["internal/exception_safety_testing.cc"], 374 hdrs = ["internal/exception_safety_testing.h"], 375 copts = ABSL_TEST_COPTS, 376 linkopts = ABSL_DEFAULT_LINKOPTS, 377 deps = [ 378 ":config", 379 ":pretty_function", 380 "//absl/memory", 381 "//absl/meta:type_traits", 382 "//absl/strings", 383 "//absl/utility", 384 "@com_google_googletest//:gtest", 385 ], 386) 387 388cc_test( 389 name = "exception_safety_testing_test", 390 srcs = ["exception_safety_testing_test.cc"], 391 copts = ABSL_TEST_COPTS, 392 linkopts = ABSL_DEFAULT_LINKOPTS, 393 deps = [ 394 ":exception_safety_testing", 395 "//absl/memory", 396 "@com_google_googletest//:gtest_main", 397 ], 398) 399 400cc_test( 401 name = "inline_variable_test", 402 size = "small", 403 srcs = [ 404 "inline_variable_test.cc", 405 "inline_variable_test_a.cc", 406 "inline_variable_test_b.cc", 407 "internal/inline_variable_testing.h", 408 ], 409 copts = ABSL_TEST_COPTS, 410 linkopts = ABSL_DEFAULT_LINKOPTS, 411 deps = [ 412 ":base_internal", 413 "@com_google_googletest//:gtest_main", 414 ], 415) 416 417cc_test( 418 name = "invoke_test", 419 size = "small", 420 srcs = ["invoke_test.cc"], 421 copts = ABSL_TEST_COPTS, 422 linkopts = ABSL_DEFAULT_LINKOPTS, 423 deps = [ 424 ":base_internal", 425 "//absl/memory", 426 "//absl/strings", 427 "@com_google_googletest//:gtest_main", 428 ], 429) 430 431# Common test library made available for use in non-absl code that overrides 432# AbslInternalSpinLockDelay and AbslInternalSpinLockWake. 433cc_library( 434 name = "spinlock_test_common", 435 testonly = 1, 436 srcs = ["spinlock_test_common.cc"], 437 copts = ABSL_TEST_COPTS, 438 linkopts = ABSL_DEFAULT_LINKOPTS, 439 deps = [ 440 ":base", 441 ":base_internal", 442 ":config", 443 ":core_headers", 444 "//absl/synchronization", 445 "@com_google_googletest//:gtest", 446 ], 447 alwayslink = 1, 448) 449 450cc_test( 451 name = "spinlock_test", 452 size = "medium", 453 srcs = ["spinlock_test_common.cc"], 454 copts = ABSL_TEST_COPTS, 455 linkopts = ABSL_DEFAULT_LINKOPTS, 456 tags = [ 457 "no_test_wasm", 458 ], 459 deps = [ 460 ":base", 461 ":base_internal", 462 ":config", 463 ":core_headers", 464 "//absl/synchronization", 465 "@com_google_googletest//:gtest_main", 466 ], 467) 468 469cc_library( 470 name = "spinlock_benchmark_common", 471 testonly = 1, 472 srcs = ["internal/spinlock_benchmark.cc"], 473 copts = ABSL_TEST_COPTS, 474 linkopts = ABSL_DEFAULT_LINKOPTS, 475 visibility = [ 476 "//absl/base:__pkg__", 477 ], 478 deps = [ 479 ":base", 480 ":base_internal", 481 ":raw_logging_internal", 482 "//absl/synchronization", 483 "@com_github_google_benchmark//:benchmark_main", 484 ], 485 alwayslink = 1, 486) 487 488cc_binary( 489 name = "spinlock_benchmark", 490 testonly = 1, 491 copts = ABSL_DEFAULT_COPTS, 492 linkopts = ABSL_DEFAULT_LINKOPTS, 493 tags = ["benchmark"], 494 visibility = ["//visibility:private"], 495 deps = [ 496 ":spinlock_benchmark_common", 497 ], 498) 499 500cc_library( 501 name = "endian", 502 hdrs = [ 503 "internal/endian.h", 504 "internal/unaligned_access.h", 505 ], 506 copts = ABSL_DEFAULT_COPTS, 507 linkopts = ABSL_DEFAULT_LINKOPTS, 508 deps = [ 509 ":base", 510 ":config", 511 ":core_headers", 512 ], 513) 514 515cc_test( 516 name = "endian_test", 517 srcs = ["internal/endian_test.cc"], 518 copts = ABSL_TEST_COPTS, 519 deps = [ 520 ":config", 521 ":endian", 522 "@com_google_googletest//:gtest_main", 523 ], 524) 525 526cc_test( 527 name = "config_test", 528 srcs = ["config_test.cc"], 529 copts = ABSL_TEST_COPTS, 530 linkopts = ABSL_DEFAULT_LINKOPTS, 531 deps = [ 532 ":config", 533 "//absl/synchronization:thread_pool", 534 "@com_google_googletest//:gtest_main", 535 ], 536) 537 538cc_test( 539 name = "call_once_test", 540 srcs = ["call_once_test.cc"], 541 copts = ABSL_TEST_COPTS, 542 linkopts = ABSL_DEFAULT_LINKOPTS, 543 deps = [ 544 ":base", 545 ":core_headers", 546 "//absl/synchronization", 547 "@com_google_googletest//:gtest_main", 548 ], 549) 550 551cc_test( 552 name = "raw_logging_test", 553 srcs = ["raw_logging_test.cc"], 554 copts = ABSL_TEST_COPTS, 555 linkopts = ABSL_DEFAULT_LINKOPTS, 556 deps = [ 557 ":raw_logging_internal", 558 "//absl/strings", 559 "@com_google_googletest//:gtest_main", 560 ], 561) 562 563cc_test( 564 name = "sysinfo_test", 565 size = "small", 566 srcs = ["internal/sysinfo_test.cc"], 567 copts = ABSL_TEST_COPTS, 568 linkopts = ABSL_DEFAULT_LINKOPTS, 569 deps = [ 570 ":base", 571 "//absl/synchronization", 572 "@com_google_googletest//:gtest_main", 573 ], 574) 575 576cc_test( 577 name = "low_level_alloc_test", 578 size = "medium", 579 srcs = ["internal/low_level_alloc_test.cc"], 580 copts = ABSL_TEST_COPTS, 581 linkopts = ABSL_DEFAULT_LINKOPTS, 582 tags = [ 583 "no_test_ios_x86_64", 584 "no_test_wasm", 585 ], 586 deps = [ 587 ":malloc_internal", 588 "//absl/container:node_hash_map", 589 ], 590) 591 592cc_test( 593 name = "thread_identity_test", 594 size = "small", 595 srcs = ["internal/thread_identity_test.cc"], 596 copts = ABSL_TEST_COPTS, 597 linkopts = ABSL_DEFAULT_LINKOPTS, 598 tags = [ 599 "no_test_wasm", 600 ], 601 deps = [ 602 ":base", 603 ":core_headers", 604 "//absl/synchronization", 605 "@com_google_googletest//:gtest_main", 606 ], 607) 608 609cc_test( 610 name = "thread_identity_benchmark", 611 srcs = ["internal/thread_identity_benchmark.cc"], 612 copts = ABSL_TEST_COPTS, 613 linkopts = ABSL_DEFAULT_LINKOPTS, 614 tags = ["benchmark"], 615 visibility = ["//visibility:private"], 616 deps = [ 617 ":base", 618 "//absl/synchronization", 619 "@com_github_google_benchmark//:benchmark_main", 620 ], 621) 622 623cc_library( 624 name = "scoped_set_env", 625 testonly = 1, 626 srcs = ["internal/scoped_set_env.cc"], 627 hdrs = ["internal/scoped_set_env.h"], 628 linkopts = ABSL_DEFAULT_LINKOPTS, 629 visibility = [ 630 "//absl:__subpackages__", 631 ], 632 deps = [ 633 ":config", 634 ":raw_logging_internal", 635 ], 636) 637 638cc_test( 639 name = "scoped_set_env_test", 640 size = "small", 641 srcs = ["internal/scoped_set_env_test.cc"], 642 copts = ABSL_TEST_COPTS, 643 linkopts = ABSL_DEFAULT_LINKOPTS, 644 deps = [ 645 ":scoped_set_env", 646 "@com_google_googletest//:gtest_main", 647 ], 648) 649 650cc_test( 651 name = "log_severity_test", 652 size = "small", 653 srcs = ["log_severity_test.cc"], 654 copts = ABSL_TEST_COPTS, 655 linkopts = ABSL_DEFAULT_LINKOPTS, 656 deps = [ 657 ":log_severity", 658 "//absl/flags:flag_internal", 659 "//absl/flags:marshalling", 660 "//absl/strings", 661 "@com_google_googletest//:gtest_main", 662 ], 663) 664 665cc_library( 666 name = "strerror", 667 srcs = ["internal/strerror.cc"], 668 hdrs = ["internal/strerror.h"], 669 copts = ABSL_DEFAULT_COPTS, 670 linkopts = ABSL_DEFAULT_LINKOPTS, 671 visibility = [ 672 "//absl:__subpackages__", 673 ], 674 deps = [ 675 ":config", 676 ":core_headers", 677 ":errno_saver", 678 ], 679) 680 681cc_test( 682 name = "strerror_test", 683 size = "small", 684 srcs = ["internal/strerror_test.cc"], 685 copts = ABSL_TEST_COPTS, 686 linkopts = ABSL_DEFAULT_LINKOPTS, 687 deps = [ 688 ":strerror", 689 "//absl/strings", 690 "@com_google_googletest//:gtest_main", 691 ], 692) 693 694cc_binary( 695 name = "strerror_benchmark", 696 testonly = 1, 697 srcs = ["internal/strerror_benchmark.cc"], 698 copts = ABSL_TEST_COPTS, 699 linkopts = ABSL_DEFAULT_LINKOPTS, 700 tags = ["benchmark"], 701 visibility = ["//visibility:private"], 702 deps = [ 703 ":strerror", 704 "@com_github_google_benchmark//:benchmark_main", 705 ], 706) 707 708cc_library( 709 name = "fast_type_id", 710 hdrs = ["internal/fast_type_id.h"], 711 copts = ABSL_DEFAULT_COPTS, 712 linkopts = ABSL_DEFAULT_LINKOPTS, 713 visibility = [ 714 "//absl:__subpackages__", 715 ], 716 deps = [ 717 ":config", 718 ], 719) 720 721cc_test( 722 name = "fast_type_id_test", 723 size = "small", 724 srcs = ["internal/fast_type_id_test.cc"], 725 copts = ABSL_TEST_COPTS, 726 linkopts = ABSL_DEFAULT_LINKOPTS, 727 deps = [ 728 ":fast_type_id", 729 "@com_google_googletest//:gtest_main", 730 ], 731) 732 733cc_library( 734 name = "prefetch", 735 hdrs = ["internal/prefetch.h"], 736 copts = ABSL_DEFAULT_COPTS, 737 linkopts = ABSL_DEFAULT_LINKOPTS, 738 visibility = [ 739 "//absl:__subpackages__", 740 ], 741 deps = [ 742 ":config", 743 ], 744) 745 746cc_test( 747 name = "prefetch_test", 748 size = "small", 749 srcs = ["internal/prefetch_test.cc"], 750 copts = ABSL_TEST_COPTS, 751 linkopts = ABSL_DEFAULT_LINKOPTS, 752 deps = [ 753 ":prefetch", 754 "@com_google_googletest//:gtest_main", 755 ], 756) 757 758cc_test( 759 name = "unique_small_name_test", 760 size = "small", 761 srcs = ["internal/unique_small_name_test.cc"], 762 copts = ABSL_TEST_COPTS, 763 linkopts = ABSL_DEFAULT_LINKOPTS, 764 linkstatic = 1, 765 deps = [ 766 ":core_headers", 767 "//absl/strings", 768 "@com_google_googletest//:gtest_main", 769 ], 770) 771 772cc_test( 773 name = "optimization_test", 774 size = "small", 775 srcs = ["optimization_test.cc"], 776 copts = ABSL_TEST_COPTS, 777 linkopts = ABSL_DEFAULT_LINKOPTS, 778 deps = [ 779 ":core_headers", 780 "//absl/types:optional", 781 "@com_google_googletest//:gtest_main", 782 ], 783) 784