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