Commit 70c49da
authored
feat: add compat.c-ares 1.34.5 (#149)
The last index-side piece before grpc-m: with abseil, protobuf(+upb), re2 and
now c-ares, the gRPC package has to vendor only gRPC's own source.
WHY IT IS HERE AT ALL. An earlier plan was to ship the first gRPC without
c-ares, since upstream has a sanctioned knob (grpc_no_ares=true → GRPC_ARES=0).
That was the wrong call: gRPC enables c-ares by default and so does everyone
else, and an index package should not quietly ship less than upstream. The
shape is default-on, switchable off — grpc-m will carry Cargo-style
`[features] default = ["ares"]` and consumers turn it off with
`default-features = false`.
It cannot be built the other way round. mcpp features are ADDITIVE, so putting
-DGRPC_ARES=0 in the base flags and having the feature flip it to 1 would put
both on the command line. The off-switch therefore lives in grpc-m's
build.mcpp (emit GRPC_ARES=0 only when the feature is absent, and drop the 7
ares TUs), while the dependency stays declarative in [feature-deps.ares] —
build.mcpp is explicitly not allowed to add a registry dependency.
SHAPE. c-ares normally learns about its host from configure/CMake writing
ares_config.h. That step is replaced by a frozen per-OS snapshot under
generated_files — the same shape compat.ffmpeg / compat.curl / compat.sdl2
already use. The upstream RELEASE tarball (a `make dist` product, not the tag
archive) already ships include/ares_build.h and src/lib/config-win32.h, so
neither is synthesized here.
The snapshots are gRPC 1.83.0's own third_party/cares/config_{linux,darwin,
windows}/ares_config.h. Not borrowed at random: gRPC pins c-ares at exactly
this release (submodule d3a507e == tag v1.34.5) and maintains those files
precisely so the library can be built without c-ares' own build system.
KNOWN TRADE-OFF, recorded rather than hidden: those snapshots are more
conservative than 1.34.5's ares_config.h.cmake template — 96 of the template's
143 HAVE_* symbols, missing HAVE_EPOLL, HAVE_GETIFADDRS, HAVE_GETRANDOM,
HAVE_IF_NAMETOINDEX among others. Missing means 0, so c-ares takes portable
fallbacks (poll rather than epoll). All 91 TUs compile with zero warnings, so
this is a performance/feature degradation, not a functional gap; regenerating
richer snapshots from c-ares' own CMake is a follow-up.
Flags are upstream's (gRPC third_party/cares/cares.BUILD). Two are
load-bearing rather than hygiene: HAVE_CONFIG_H is what makes
src/lib/ares_setup.h include ares_config.h at all, and _GNU_SOURCE is required
on glibc — without it <unistd.h>/<string.h> hide gethostname, clock_gettime,
strcasecmp and getservbyport_r, and four TUs fail with implicit-declaration
errors. src/lib/**/*.c is safe to glob: upstream keeps tests and tools in
test/ and src/tools/, and no TU under src/lib defines main().
Verified cold with the pinned mcpp 2026.8.3.3, gcc@16.1.0,
MCPP_INDEX_MIRROR=GLOBAL, MCPP_BUILD_CACHE=local, target/ and .mcpp/ removed
first: `test result ok`, 92 objects linked (91 sources + the test).
The test is entirely OFFLINE — it never sends a DNS query, so it does not
depend on the runner's name resolution. It covers library init/cleanup, a
channel with options, a set/get round trip of the server list as CSV (real
string + record parsing), ares_inet_pton/ntop both ways, and ares_strerror,
and it asserts that malformed input is REJECTED (a bad server CSV,
"999.1.1.1") — otherwise "parsing succeeded" would prove nothing. It also
asserts the version is 1.34.5, so a silently different vendored version cannot
pass.
CN mirror published and closed-loop checked: mcpp-res/c-ares@1.34.5 returns
http=200 and is byte-identical to GLOBAL. Cross-package basename check: c-ares
collides with none of abseil / protobuf / upb / re2.
Alongside this, gRPC 1.83.0 was compiled in full with mcpp's gcc@16.1.0 —
1001 TUs (999 gRPC sources + 2 third_party/address_sorting), including the
resolver path that goes through this package's real headers and config
snapshot. The only extra include dirs needed are third_party/address_sorting/
include and third_party/xxhash, both of which have real content in gRPC's own
tree, and the only file that must be excluded is
src/core/ext/upb-gen/google/protobuf/descriptor.upb_minitable.c — byte-for-byte
identical to the bootstrap copy compat.protobuf's upb feature already brings.1 parent 320d024 commit 70c49da
7 files changed
Lines changed: 1603 additions & 2 deletions
File tree
- .agents/docs
- pkgs/c
- tests/examples/c-ares
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
0 commit comments