From c2c18fb6ae84eabfa1345f18794ba69ee432610e Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Fri, 20 Dec 2024 22:24:37 +0000 Subject: [PATCH] Remove bazel cpu constraints usage 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. ``` --- absl/copts/configure_copts.bzl | 36 ++++---------------------------- absl/random/internal/BUILD.bazel | 3 --- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/absl/copts/configure_copts.bzl b/absl/copts/configure_copts.bzl index ca5f26daa6b..fda8873743f 100644 --- a/absl/copts/configure_copts.bzl +++ b/absl/copts/configure_copts.bzl @@ -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", @@ -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}, - ) diff --git a/absl/random/internal/BUILD.bazel b/absl/random/internal/BUILD.bazel index cf4b8f34f2c..61b85b33844 100644 --- a/absl/random/internal/BUILD.bazel +++ b/absl/random/internal/BUILD.bazel @@ -21,7 +21,6 @@ load( "ABSL_DEFAULT_LINKOPTS", "ABSL_RANDOM_RANDEN_COPTS", "ABSL_TEST_COPTS", - "absl_random_randen_copts_init", ) default_package_visibility = [ @@ -321,8 +320,6 @@ cc_library( ], ) -absl_random_randen_copts_init() - cc_library( name = "randen_hwaes", srcs = [