Skip to content

Conversation

@mmorel-35
Copy link
Contributor

This PR addresses the request to modernize the Abseil dependency management by replacing the custom Bazel extension with a standard bazel_dep and eliminating the need for source patching.

Problem

The current setup used a custom Bazel extension (extensions.bzl) to download Abseil via http_archive and apply a source patch (abseil.patch) to modify absl/base/options.h. The patch forced Abseil to not use C++ standard library types:

-#define ABSL_OPTION_USE_STD_OPTIONAL 2
+#define ABSL_OPTION_USE_STD_OPTIONAL 0

This approach had several downsides:

  • Required maintaining a custom extension
  • Needed source patching which is fragile and non-standard
  • Used an older Abseil commit instead of tagged releases

Solution

1. Replaced extension with direct bazel_dep

# Before: Custom extension
non_module_dependencies = use_extension("//:extensions.bzl", "non_module_dependencies")
use_repo(non_module_dependencies, "com_google_absl")

# After: Standard bazel_dep
bazel_dep(
    name = "abseil-cpp",
    version = "20230125.3",
    repo_name = "com_google_absl",
)

2. Replaced patch with compile-time configuration

Instead of patching source files, the same behavior is achieved through C++ preprocessor defines in .bazelrc.absl:

--cxxopt='-DABSL_OPTION_USE_STD_OPTIONAL=0'
--cxxopt='-DABSL_OPTION_USE_STD_STRING_VIEW=0' 
--cxxopt='-DABSL_OPTION_USE_STD_VARIANT=0'

These defines are applied for all platforms (Linux, macOS, Windows) alongside the existing DD_USE_ABSEIL_FOR_ENVOY macro.

@mmorel-35 mmorel-35 marked this pull request as ready for review September 11, 2025 17:33
@mmorel-35 mmorel-35 requested a review from a team as a code owner September 11, 2025 17:33
@mmorel-35 mmorel-35 requested review from dubloom and removed request for a team September 11, 2025 17:33
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Copy link
Collaborator

@dmehala dmehala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. LGTM :shipit:

@dmehala dmehala merged commit ae0d9a3 into DataDog:main Sep 14, 2025
15 of 21 checks passed
@mmorel-35 mmorel-35 deleted the module/abseil-cpp branch September 14, 2025 16:34
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.

2 participants