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