Skip to content

Default GTEST_HAS_ABSL=1 since abseil is an unconditional dep (fixes #4953)#4970

Open
dokson wants to merge 1 commit into
google:mainfrom
dokson:fix/4953-default-has-absl-on
Open

Default GTEST_HAS_ABSL=1 since abseil is an unconditional dep (fixes #4953)#4970
dokson wants to merge 1 commit into
google:mainfrom
dokson:fix/4953-default-has-absl-on

Conversation

@dokson
Copy link
Copy Markdown

@dokson dokson commented May 3, 2026

Summary

Fixes #4953.

abseil-cpp is loaded unconditionally both under bzlmod (via bazel_dep in MODULE.bazel) and under WORKSPACE (via googletest_deps() in googletest_deps.bzl), but GTEST_HAS_ABSL was only defined when the user passed --define absl=1. As a result, features gated on the macro — AbslStringify support in gtest-message.h / gtest-printers.h, abseil-based flag parsing, the failure-signal handler — silently stayed off even though the abseil dependency was already in the build graph.

This flips the default: abseil integration is enabled by default; users can opt out with --define absl=0.

Changes (single file: BUILD.bazel)

  • Replace config_setting(name = "has_absl", values = {"define": "absl=1"}) with config_setting(name = "absl_disabled", values = {"define": "absl=0"}).
  • Invert the two select() callsites so GTEST_HAS_ABSL=1 and the abseil deps are the default branch and the empty list is selected only when absl=0.
  • Extract the abseil deps list into a top-level _ABSL_DEPS variable.

Backward compatibility

  • --define absl=1 continues to be accepted (silent no-op now, since absl is enabled by default).
  • --define absl=0 is a new explicit opt-out for users who don't want the abseil integration even though the dependency is loaded.
  • No new bazel_dep is introduced. MODULE.bazel and googletest_deps.bzl are untouched.

Validation

Tested locally on Windows / MSVC 14.44 with bazelisk + Bazel 9.1.0:

  1. bazelisk build //:gtest → success, abseil headers in inputs of gtest compile actions.
  2. Probe with #error if GTEST_HAS_ABSL != 1: compiles by default → macro is set as expected.
  3. Probe with #error if GTEST_HAS_ABSL == 1: compiles only with --define absl=0 → opt-out works.

(Probe targets were used during validation only and are not part of this diff.)

abseil-cpp is loaded unconditionally under bzlmod (via bazel_dep) and
under WORKSPACE (via googletest_deps()), but GTEST_HAS_ABSL was only
defined when the user passed --define absl=1. As a result, features
gated on the macro (AbslStringify support, absl::flags parsing, the
failure-signal handler) silently stayed off even though the abseil
dependency was being pulled in.

Flip the default: enable absl integration by default and let users
opt out with --define absl=0. Existing scripts passing --define absl=1
keep working as a no-op. Also extract the absl deps list into a local
variable to avoid duplication.

Fixes google#4953
@dokson dokson marked this pull request as ready for review May 3, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: has_absl should default to true when using bzlmod

1 participant