Skip to content

Build gRPC without c-ares - #32649

Closed
fmeum wants to merge 4 commits into
bazelbuild:masterfrom
fmeum:grpc-no-ares
Closed

fmeum wants to merge 4 commits into
bazelbuild:masterfrom
fmeum:grpc-no-ares

Conversation

@fmeum

@fmeum fmeum commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

The Bazel client only connects to the server via 127.0.0.1 or [::1] (enforced in BlazeServer::TryConnect), so it never needs DNS resolution. For IP literals, gRPC doesn't consult the resolver anyway. This PR sets --define=grpc_no_ares=true so that gRPC is built with GRPC_ARES=0 and c-ares drops out of the build graph of //src:bazel entirely, which also removes the c-ares compiler warnings (unused function/variable, deprecated c-ares APIs used by gRPC). Since c-ares is no longer built, its version override and its entry in the distribution archive are removed as well. envoy_api, googleapis-grpc-java, googleapis-java, opencensus-cpp, rules_fuzzing and toml.bzl are also dropped from the distribution archive, since a build of Bazel no longer fetches them.

The Bazel client only connects to the server via 127.0.0.1 or [::1] (see
BlazeServer::TryConnect), so it never needs DNS resolution. Disabling gRPC's
c-ares based resolver avoids building c-ares (and its warnings) and shrinks
the client binary by ~350 KB.
@fmeum
fmeum marked this pull request as ready for review November 13, 2026 19:34
@fmeum
fmeum requested a review from meisterT November 13, 2026 19:35
@github-actions github-actions Bot added the awaiting-review PR is awaiting review from an assigned reviewer label Nov 13, 2026

@tjgq tjgq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! Should we also set the define in scripts/bootstrap/bootstrap.sh? (might speed up bootstrap a bit, don't know how much code this is)

@fmeum
fmeum requested a review from tjgq November 14, 2026 09:40

@tjgq tjgq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we now remove c-ares from MODULE.bazel and repositories.bzl? (Sorry, I should have also mentioned this earlier)

c-ares is no longer built, so it needs neither a version override nor a place in the distribution archive. It remains in the module graph as a dependency of gRPC.
@fmeum
fmeum requested a review from tjgq November 14, 2026 23:35
None of envoy_api, googleapis-grpc-java, googleapis-java, opencensus-cpp, rules_fuzzing and toml.bzl is fetched when analyzing //src:bazel or //src:bazel_nojdk, and none of them is loaded on any select branch. Bazel uses gRPC's unsecure targets, which don't depend on xDS and thus envoy_api. toml.bzl was only loaded by the pip extension, which the bootstrap no longer evaluates since 53824fa.
@tjgq tjgq added copybara:import Trigger copybara to import the PR and removed awaiting-review PR is awaiting review from an assigned reviewer labels Nov 15, 2026
copybara-service Bot pushed a commit that referenced this pull request Nov 17, 2026
Fixes the Bazel-side warnings printed by `bazel build --config=llvm //src:bazel-dev` on a clean output base:

* Replace the `--cpu`-based `config_setting`s in `//src/conditions`, which trigger a deprecation warning (`select() on cpu is deprecated`), with the existing constraint-based ones. Bazel CI doesn't use `--cpu` anymore.
* Set `legacy_create_init = 0` on Bazel's own `py_binary` targets (`//src:create_embedded_tools`, `//tools/build_defs/proguard:wrapper_private`) to address the rules_python implicit `__init__.py` deprecation.
* Drop the explicit `jar` packaging from Maven coordinates (`Assuming ... should be interpreted as ...`) and declare `known_contributing_modules` for the `maven` repo. `maven_install.json` only changes its input hash.
* Only pass the `java_proto_library` for the service to `java_grpc_library`, as multiple `deps` are deprecated. The longrunning protos are covered transitively.
* Exclude incubator modules from the "all modules" embedded JDK, which jlink warns about (`Using incubator modules: jdk.incubator.vector`) and Bazel doesn't use.

Remaining warnings are fixed elsewhere and will be picked up by follow-up dependency updates:

* c-ares: #32649 (drop c-ares), bazelbuild/bazel-central-registry#11756
* zstd-jni: bazelbuild/bazel-central-registry#11757 (zstd-jni 1.5.7-26)
* protobuf: deprecated `GetEnum`/`GetRepeatedEnum` calls are fixed in protobuf 37.0
* rules_pkg: bazelbuild/rules_pkg#1097
* gRPC: grpc/grpc#43933, grpc/grpc-java#13188
* Mirror: #32646

Closes #32651

COPYBARA_INTEGRATE_REVIEW=#32651 from fmeum:fix-build-warnings 5f5e9c3
PiperOrigin-RevId: 1023592606
Change-Id: Ia04594ff9c771f596c291bf0d4785915124c6a5a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copybara:import Trigger copybara to import the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants