BUILD.bazel (9878B)
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 17 load( 18 "//absl:copts/configure_copts.bzl", 19 "ABSL_DEFAULT_COPTS", 20 "ABSL_DEFAULT_LINKOPTS", 21 "ABSL_TEST_COPTS", 22 ) 23 24 package( 25 default_visibility = ["//visibility:private"], 26 features = [ 27 "header_modules", 28 "layering_check", 29 "parse_headers", 30 ], 31 ) 32 33 licenses(["notice"]) 34 35 # Internal data structure for efficiently detecting mutex dependency cycles 36 cc_library( 37 name = "graphcycles_internal", 38 srcs = [ 39 "internal/graphcycles.cc", 40 ], 41 hdrs = [ 42 "internal/graphcycles.h", 43 ], 44 copts = ABSL_DEFAULT_COPTS + select({ 45 "//conditions:default": [], 46 }), 47 linkopts = ABSL_DEFAULT_LINKOPTS, 48 deps = [ 49 "//absl/base", 50 "//absl/base:base_internal", 51 "//absl/base:config", 52 "//absl/base:core_headers", 53 "//absl/base:malloc_internal", 54 "//absl/base:raw_logging_internal", 55 ], 56 ) 57 58 cc_library( 59 name = "kernel_timeout_internal", 60 srcs = ["internal/kernel_timeout.cc"], 61 hdrs = ["internal/kernel_timeout.h"], 62 copts = ABSL_DEFAULT_COPTS, 63 linkopts = ABSL_DEFAULT_LINKOPTS, 64 visibility = [ 65 ], 66 deps = [ 67 "//absl/base", 68 "//absl/base:config", 69 "//absl/base:core_headers", 70 "//absl/base:raw_logging_internal", 71 "//absl/time", 72 ] + select({ 73 "//conditions:default": [], 74 }), 75 ) 76 77 cc_test( 78 name = "kernel_timeout_internal_test", 79 srcs = ["internal/kernel_timeout_test.cc"], 80 copts = ABSL_TEST_COPTS, 81 flaky = 1, 82 linkopts = ABSL_DEFAULT_LINKOPTS, 83 deps = [ 84 ":kernel_timeout_internal", 85 "//absl/base:config", 86 "//absl/random", 87 "//absl/time", 88 "@googletest//:gtest", 89 "@googletest//:gtest_main", 90 ], 91 ) 92 93 cc_library( 94 name = "synchronization", 95 srcs = [ 96 "barrier.cc", 97 "blocking_counter.cc", 98 "internal/create_thread_identity.cc", 99 "internal/futex_waiter.cc", 100 "internal/per_thread_sem.cc", 101 "internal/pthread_waiter.cc", 102 "internal/sem_waiter.cc", 103 "internal/stdcpp_waiter.cc", 104 "internal/waiter_base.cc", 105 "internal/win32_waiter.cc", 106 "mutex.cc", 107 "notification.cc", 108 ], 109 hdrs = [ 110 "barrier.h", 111 "blocking_counter.h", 112 "internal/create_thread_identity.h", 113 "internal/futex.h", 114 "internal/futex_waiter.h", 115 "internal/per_thread_sem.h", 116 "internal/pthread_waiter.h", 117 "internal/sem_waiter.h", 118 "internal/stdcpp_waiter.h", 119 "internal/waiter.h", 120 "internal/waiter_base.h", 121 "internal/win32_waiter.h", 122 "mutex.h", 123 "notification.h", 124 ], 125 copts = ABSL_DEFAULT_COPTS, 126 linkopts = select({ 127 "@rules_cc//cc/compiler:msvc-cl": [], 128 "@rules_cc//cc/compiler:clang-cl": [], 129 "@rules_cc//cc/compiler:emscripten": [], 130 "//conditions:default": ["-pthread"], 131 }) + ABSL_DEFAULT_LINKOPTS, 132 visibility = ["//visibility:public"], 133 deps = [ 134 ":graphcycles_internal", 135 ":kernel_timeout_internal", 136 "//absl/base", 137 "//absl/base:atomic_hook", 138 "//absl/base:base_internal", 139 "//absl/base:config", 140 "//absl/base:core_headers", 141 "//absl/base:dynamic_annotations", 142 "//absl/base:malloc_internal", 143 "//absl/base:nullability", 144 "//absl/base:raw_logging_internal", 145 "//absl/base:tracing_internal", 146 "//absl/debugging:stacktrace", 147 "//absl/debugging:symbolize", 148 "//absl/time", 149 ] + select({ 150 "//conditions:default": [], 151 }), 152 ) 153 154 cc_test( 155 name = "barrier_test", 156 size = "small", 157 srcs = ["barrier_test.cc"], 158 copts = ABSL_TEST_COPTS, 159 linkopts = ABSL_DEFAULT_LINKOPTS, 160 tags = [ 161 "no_test_wasm", # b/122473323 162 ], 163 deps = [ 164 ":synchronization", 165 "//absl/time", 166 "@googletest//:gtest", 167 "@googletest//:gtest_main", 168 ], 169 ) 170 171 cc_test( 172 name = "blocking_counter_test", 173 size = "small", 174 srcs = ["blocking_counter_test.cc"], 175 copts = ABSL_TEST_COPTS, 176 linkopts = ABSL_DEFAULT_LINKOPTS, 177 tags = [ 178 "no_test_wasm", # b/122473323 179 ], 180 deps = [ 181 ":synchronization", 182 "//absl/base:config", 183 "//absl/base:core_headers", 184 "//absl/base:tracing_internal", 185 "//absl/time", 186 "@googletest//:gtest", 187 "@googletest//:gtest_main", 188 ], 189 ) 190 191 cc_binary( 192 name = "blocking_counter_benchmark", 193 testonly = True, 194 srcs = ["blocking_counter_benchmark.cc"], 195 copts = ABSL_TEST_COPTS, 196 linkopts = ABSL_DEFAULT_LINKOPTS, 197 tags = ["benchmark"], 198 deps = [ 199 ":synchronization", 200 ":thread_pool", 201 "//absl/base:no_destructor", 202 "@google_benchmark//:benchmark_main", 203 ], 204 ) 205 206 cc_test( 207 name = "graphcycles_test", 208 size = "medium", 209 srcs = ["internal/graphcycles_test.cc"], 210 copts = ABSL_TEST_COPTS, 211 linkopts = ABSL_DEFAULT_LINKOPTS, 212 deps = [ 213 ":graphcycles_internal", 214 "//absl/base:core_headers", 215 "//absl/log", 216 "//absl/log:check", 217 "@googletest//:gtest", 218 "@googletest//:gtest_main", 219 ], 220 ) 221 222 cc_test( 223 name = "graphcycles_benchmark", 224 srcs = ["internal/graphcycles_benchmark.cc"], 225 copts = ABSL_TEST_COPTS, 226 linkopts = ABSL_DEFAULT_LINKOPTS, 227 tags = [ 228 "benchmark", 229 ], 230 deps = [ 231 ":graphcycles_internal", 232 "//absl/base:raw_logging_internal", 233 "@google_benchmark//:benchmark_main", 234 ], 235 ) 236 237 cc_library( 238 name = "thread_pool", 239 testonly = True, 240 hdrs = ["internal/thread_pool.h"], 241 linkopts = ABSL_DEFAULT_LINKOPTS, 242 visibility = [ 243 "//absl:__subpackages__", 244 ], 245 deps = [ 246 ":synchronization", 247 "//absl/base:core_headers", 248 "//absl/functional:any_invocable", 249 ], 250 ) 251 252 cc_test( 253 name = "mutex_test", 254 size = "large", 255 srcs = ["mutex_test.cc"], 256 copts = ABSL_TEST_COPTS, 257 flaky = 1, 258 linkopts = ABSL_DEFAULT_LINKOPTS, 259 shard_count = 25, 260 deps = [ 261 ":synchronization", 262 ":thread_pool", 263 "//absl/base", 264 "//absl/base:config", 265 "//absl/base:core_headers", 266 "//absl/log", 267 "//absl/log:check", 268 "//absl/memory", 269 "//absl/time", 270 "@googletest//:gtest", 271 "@googletest//:gtest_main", 272 ], 273 ) 274 275 cc_test( 276 name = "mutex_method_pointer_test", 277 srcs = ["mutex_method_pointer_test.cc"], 278 copts = ABSL_TEST_COPTS, 279 linkopts = ABSL_DEFAULT_LINKOPTS, 280 deps = [ 281 ":synchronization", 282 "//absl/base:config", 283 "@googletest//:gtest", 284 "@googletest//:gtest_main", 285 ], 286 ) 287 288 cc_library( 289 name = "mutex_benchmark_common", 290 testonly = True, 291 srcs = ["mutex_benchmark.cc"], 292 copts = ABSL_TEST_COPTS, 293 linkopts = ABSL_DEFAULT_LINKOPTS, 294 visibility = [ 295 ], 296 deps = [ 297 ":synchronization", 298 ":thread_pool", 299 "//absl/base", 300 "//absl/base:config", 301 "//absl/base:no_destructor", 302 "@google_benchmark//:benchmark_main", 303 ], 304 alwayslink = 1, 305 ) 306 307 cc_binary( 308 name = "mutex_benchmark", 309 testonly = True, 310 copts = ABSL_DEFAULT_COPTS, 311 linkopts = ABSL_DEFAULT_LINKOPTS, 312 deps = [ 313 ":mutex_benchmark_common", 314 ], 315 ) 316 317 cc_test( 318 name = "notification_test", 319 size = "small", 320 srcs = ["notification_test.cc"], 321 copts = ABSL_TEST_COPTS, 322 flaky = 1, 323 linkopts = ABSL_DEFAULT_LINKOPTS, 324 tags = ["no_test_lexan"], 325 deps = [ 326 ":synchronization", 327 "//absl/base:config", 328 "//absl/base:core_headers", 329 "//absl/base:tracing_internal", 330 "//absl/time", 331 "@googletest//:gtest", 332 "@googletest//:gtest_main", 333 ], 334 ) 335 336 cc_library( 337 name = "per_thread_sem_test_common", 338 testonly = True, 339 srcs = ["internal/per_thread_sem_test.cc"], 340 copts = ABSL_TEST_COPTS, 341 linkopts = ABSL_DEFAULT_LINKOPTS, 342 visibility = [ 343 ], 344 deps = [ 345 ":synchronization", 346 "//absl/base", 347 "//absl/base:config", 348 "//absl/strings", 349 "//absl/time", 350 "@googletest//:gtest", 351 ], 352 alwayslink = 1, 353 ) 354 355 cc_test( 356 name = "per_thread_sem_test", 357 size = "large", 358 copts = ABSL_TEST_COPTS, 359 linkopts = ABSL_DEFAULT_LINKOPTS, 360 tags = [ 361 "no_test_wasm", 362 ], 363 deps = [ 364 ":per_thread_sem_test_common", 365 ":synchronization", 366 "//absl/strings", 367 "//absl/time", 368 "@googletest//:gtest_main", 369 ], 370 ) 371 372 cc_test( 373 name = "waiter_test", 374 srcs = ["internal/waiter_test.cc"], 375 copts = ABSL_TEST_COPTS, 376 flaky = 1, 377 linkopts = ABSL_DEFAULT_LINKOPTS, 378 deps = [ 379 ":kernel_timeout_internal", 380 ":synchronization", 381 ":thread_pool", 382 "//absl/base:config", 383 "//absl/random", 384 "//absl/time", 385 "@googletest//:gtest", 386 "@googletest//:gtest_main", 387 ], 388 ) 389 390 cc_test( 391 name = "lifetime_test", 392 srcs = [ 393 "lifetime_test.cc", 394 ], 395 copts = ABSL_TEST_COPTS, 396 linkopts = ABSL_DEFAULT_LINKOPTS, 397 tags = [ 398 "no_test_ios_x86_64", 399 "no_test_wasm", 400 ], 401 deps = [ 402 ":synchronization", 403 "//absl/base:core_headers", 404 "//absl/log:check", 405 ], 406 )