Skip to content

Commit

Permalink
Remove bazel cpu constraints usage
Browse files Browse the repository at this point in the history
This fixes a warning in an upcoming version of bazel. This use case
seems to solvable by using platform constraints directly. Fixes:

```
WARNING: @@abseil-cpp+//absl/random/internal:cpu_aarch64: select() on cpu is deprecated. Use platform constraints instead: https://bazel.build/docs/configurable-attributes#platforms.
```
  • Loading branch information
keith committed Dec 20, 2024
1 parent 5913446 commit c2c18fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 35 deletions.
36 changes: 4 additions & 32 deletions absl/copts/configure_copts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ load(
"ABSL_MSVC_FLAGS",
"ABSL_MSVC_LINKOPTS",
"ABSL_MSVC_TEST_FLAGS",
"ABSL_RANDOM_HWAES_ARM32_FLAGS",
"ABSL_RANDOM_HWAES_ARM64_FLAGS",
"ABSL_RANDOM_HWAES_MSVC_X64_FLAGS",
"ABSL_RANDOM_HWAES_X64_FLAGS",
Expand Down Expand Up @@ -45,38 +44,11 @@ ABSL_DEFAULT_LINKOPTS = select({
# ABSL_RANDOM_RANDEN_COPTS blaze copts flags which are required by each
# environment to build an accelerated RandenHwAes library.
ABSL_RANDOM_RANDEN_COPTS = select({
# APPLE
":cpu_darwin_x86_64": ABSL_RANDOM_HWAES_X64_FLAGS,
":cpu_darwin": ABSL_RANDOM_HWAES_X64_FLAGS,
":cpu_x64_windows_msvc": ABSL_RANDOM_HWAES_MSVC_X64_FLAGS,
":cpu_x64_windows": ABSL_RANDOM_HWAES_MSVC_X64_FLAGS,
":cpu_k8": ABSL_RANDOM_HWAES_X64_FLAGS,
":cpu_ppc": ["-mcrypto"],
":cpu_aarch64": ABSL_RANDOM_HWAES_ARM64_FLAGS,
"@platforms//os:windows": ABSL_RANDOM_HWAES_MSVC_X64_FLAGS,
"@platforms//cpu:x86_64": ABSL_RANDOM_HWAES_X64_FLAGS,
"@platforms//cpu:ppc": ["-mcrypto"],
"@platforms//cpu:aarch64": ABSL_RANDOM_HWAES_ARM64_FLAGS,

# Supported by default or unsupported.
"//conditions:default": [],
})

# absl_random_randen_copts_init:
# Initialize the config targets based on cpu, os, etc. used to select
# the required values for ABSL_RANDOM_RANDEN_COPTS
def absl_random_randen_copts_init():
"""Initialize the config_settings used by ABSL_RANDOM_RANDEN_COPTS."""

# CPU configs.
# These configs have consistent flags to enable HWAES intsructions.
cpu_configs = [
"ppc",
"k8",
"darwin_x86_64",
"darwin",
"x64_windows_msvc",
"x64_windows",
"aarch64",
]
for cpu in cpu_configs:
native.config_setting(
name = "cpu_%s" % cpu,
values = {"cpu": cpu},
)
3 changes: 0 additions & 3 deletions absl/random/internal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ load(
"ABSL_DEFAULT_LINKOPTS",
"ABSL_RANDOM_RANDEN_COPTS",
"ABSL_TEST_COPTS",
"absl_random_randen_copts_init",
)

default_package_visibility = [
Expand Down Expand Up @@ -321,8 +320,6 @@ cc_library(
],
)

absl_random_randen_copts_init()

cc_library(
name = "randen_hwaes",
srcs = [
Expand Down

0 comments on commit c2c18fb

Please sign in to comment.