4 Commits

Author SHA1 Message Date
CHEN Feng 7b68301df9 thirdparty: migrate yaml-cpp to vcpkg (#185)
yaml-cpp 0.6.3 -> vcpkg 0.9.0. linkage=auto + link_all_symbols (whole-archive the static .a into the wrapper shared lib so it exports symbols -- the real cause of the convert_to_map "ABI" undefined). thirdparty-only.
2026-06-17 15:57:21 +08:00
CHEN Feng 1f5675f0df BUILD: clean up blade dep-check notices (246 -> 0) (#159)
* build_rules: let cc_flare_library accept keep_deps

`cc_flare_library` wraps a `.proto` generation step plus the resulting
`cc_library`. The wrapper's outer call doesn't expose blade's
`keep_deps` knob, so any `:protobuf` or `:flare_gen_*` dep that is
structurally required at link/runtime but not directly `#include`d
gets flagged as unused -- with no way to suppress without removing
the dep.

Forward an optional `keep_deps=` arg through to the underlying
`native.cc_library` so consumers can mark intentional link-time-only
deps. No behaviour change when `keep_deps` is not passed.

* BUILD: address blade dep-check notices

Apply the entire build64_release/build.log batch of dependency notices
(246 instances across 49 BUILD files): add deps where headers are
included but undeclared, remove deps where they're never reached by
any #include, and mark intentional-but-not-included deps as
`keep_deps` so blade stops re-flagging them.

After this change a fresh `blade build -p release flare/...` emits 0
notices (down from 246) and a `--generate-dynamic` build still links
clean across all 2376 targets.

Two visibility-related notices intentionally left in place:
  * `flare/rpc:rpc` -> `flare/rpc/protocol/http:http_{filter,handler}`
  * `flare/base:exposed_var_test` -> `//flare/base/write_mostly:metrics`
The source #includes those headers but the dep targets are restricted
to a tighter visibility set. That's a design call (open visibility vs.
hide the include) and not something to paper over here.

* BUILD: drop keep_deps obsoleted by blade dep-check improvements

After patching blade with the three dep-check fixes (blade-build#1226,
#1227, #1228), 71 keep_deps entries (across 46 targets in 19 BUILD
files) are no longer reported as false positives:

* #1226 — targets with no scannable C/C++ source (e.g. cc_flare_library
  wrappers around a .proto, foreign_cc_library, generated-only libs) no
  longer get every dep flagged as unused, since blade has no #include
  corpus to compare against.
* #1227 — headers from libraries with export_incs (notably
  thirdparty/protobuf-3.4.1) are now matched against #include directives
  using the consumer-visible relative path, so includes like
  <google/protobuf/message.h> resolve to the //thirdparty/protobuf
  target. This alone accounts for the majority of the removed keep_deps.
* #1228 — libraries that the user has placed in
  cc_library_config.hdrs_missing_suppress (gtest_main, protoc, ...) are
  now exempt from the unused-deps check by being treated as header-less,
  matching the behaviour of an explicit `hdrs = []`.

Verified with a full release build of flare/...: 0 unused-dep notices
remain. The keep_deps entries that survive are genuine link-only deps
(static-registration factories, link-only main()s, gflags providers).

* headers: add directly-used #includes that were transitively available

These three headers used identifiers from another header without a direct
#include, relying on transitive inclusion (a fragile pattern that breaks
the moment the indirect path drops the include). Make the dependencies
explicit so the blade unused-deps check matches them, and so the headers
keep compiling after upstream cleanups.

  thread_local.h        FLARE_LIKELY      -> flare/base/likely.h
  ref_counted.h         Function<>        -> flare/base/function.h
  sampler.h             FLARE_CHECK_*     -> flare/base/logging.h

* BUILD: drop deps that were never actually used

Each of these targets listed a dep that neither its hdrs nor its srcs
referenced (in some cases the original BUILD even flagged the dep with a
"???" comment). Removed:

  flare/base/internal:hash_map               //flare/base:logging
                                              (file uses internal/logging.h, not the public one)
  flare/base/thread:thread_local             keep_deps //flare/base:likely
  flare/base/thread/thread_local:ref_counted keep_deps //flare/base:function
  flare/base/thread/thread_local/detail:atomic_ptr  //flare/base:align
  flare/base/write_mostly:write_mostly       //flare/base:chrono
  flare/fiber:future                         :fiber_basic
  flare/rpc/binlog:dumper                    //flare/base/internal:index_alloc
                                              (was tagged "???" in the BUILD)
  flare/rpc/internal:sampler                 keep_deps //flare/base:logging
  flare/rpc/protocol/protobuf:rpc_controller_common  :call_context
  flare/rpc/protocol/protobuf:integration_test_*     :protobuf
                                              (transitively from //flare/rpc:rpc)

The keep_deps entries that previously masked these notices are also
gone; the three keep_deps cases above (thread_local, ref_counted,
sampler) were paired with a missing #include rather than an unused dep,
which is fixed in the previous commit.

flare/rpc:http: add a one-line comment explaining the surviving
keep_deps entry (umbrella re-export of the HTTP protocol).

* BUILD: drop keep_deps now obsoleted by foreign_cc_library auto-exempt

These keep_deps entries all listed foreign_cc_library targets (gflags,
gtest/gmock, glog, zlib, fmt, jsoncpp, ctemplate). The upcoming
blade-build patch makes foreign_cc_library targets that register only
an hdr_dir (no explicit hdrs) auto-`declare_header_less`, since the
hdr_dir path stored is the in-source build tree (e.g.
"thirdparty/gflags/gflags") which #include directives never reference,
making the unused-deps check unable to ever match them. With those
targets exempted, the keep_deps entries here become noise.

* BUILD: move keep_deps next to deps and explain every remaining entry

For every target that survives with a keep_deps, reorder the attribute
so it sits immediately after `deps` (instead of after `visibility` or
`link_all_symbols`) and add a comment block — and per-entry inline note
where the entries serve different purposes — describing WHY each entry
cannot be expressed through a normal `#include`. Two patterns recur:

  1) Umbrella facades whose hdrs are ALSO declared by the sub-targets
     they bundle. blade attributes every direct #include to the more
     specific sub-target owner, leaving the umbrella itself uncredited
     for "using" its sub-deps. (fiber, redis, http, hbase{,_client,
     _server}, tracing, rpc/protobuf)

  2) Link-time static-initializer registration with no public header.
     Each `*_protocol` and load-balancer / name-resolver sub-target
     registers itself with ServiceMethodLocator / a protocol-or-NSLB
     registry via static initializers; the consumer needs the static
     init to run at link time but has nothing to `#include`. (rpc:rpc,
     rpc:http, protobuf:{baidu_std,poppy}_protocol, the protocol
     entries of protobuf:protobuf)

No behaviour change; this is documentation + ordering.

* BUILD: drop keep_deps now handled by blade's re-export auto-exemption

With blade's new re-export auto-exemption rule (any target that shares
an `hdrs` declaration with one of its deps treats that dep as
implicitly "used"), the keep_deps entries that existed purely to silence
the umbrella -> sub-target pattern are no longer needed. blade now sees
the umbrella as legitimately depending on every sub-target whose public
header it also re-declares.

Eliminated keep_deps entries (24 across 12 targets):

  flare/fiber:fiber                 6/6   (all sub-libs re-exported)
  flare/net/redis:redis             1/1   (drops entire keep_deps)
  flare/net/hbase:hbase             2/2   (drops entire keep_deps)
  flare/net/hbase:hbase_client      2/3   (one link-time entry kept)
  flare/net/hbase:hbase_server      2/3   (one link-time entry kept)
  flare/net/http:http               3/4   (one link-time entry kept)
  flare/rpc:rpc                     3/6   (three link-time entries kept)
  flare/rpc/tracing:tracing         2/2   (drops entire keep_deps)
  protobuf:protobuf                 3/11  (eight link-time entries kept)

Remaining 17 keep_deps entries are all genuine static-initializer
registrations (NSLB / name-resolver / protocol / service registries)
that hook into a global registry with no public header for the
consumer to `#include`.

* BUILD: privatize self-registration .h files (move from hdrs to srcs)

A library whose sole purpose is to register an implementation with a
runtime registry (NSLB, name resolver, protocol, channel scheme, ...)
has no need for a public header file. Consumers reach the
implementation through the registry at link time, not by `#include`-ing
its type directly. Moving the .h into `srcs` reflects that intent and
makes the target header-less, which blade's existing
`_header_less_target_keys` mechanism automatically exempts from the
unused-deps check -- no `keep_deps` needed.

Privatized targets:

  flare/rpc/load_balancer:round_robin                  NSLB "rr"
  flare/rpc/name_resolver:list                         resolver scheme
  flare/net/http:dry_run_channel                       dry-run HTTP channel
  flare/rpc/protocol/http:http                         HTTP/1.x protocol + service
  flare/rpc/protocol/protobuf:baidu_std_protocol       protocol registration
  flare/rpc/protocol/protobuf:poppy_protocol           protocol registration
  flare/rpc/protocol/protobuf:qzone_protocol           protocol registration
  flare/rpc/protocol/protobuf:proto_over_http_protocol protocol registration
  flare/rpc/protocol/protobuf:std_protocol             protocol registration

Audit method: a target qualified iff the only out-of-target users of
its .h file are its matching `*_test.cc` -- so the public-header
contract was being used only by tests for type-level access.

Cascade effect on keep_deps blocks (12 -> 3):

  flare/rpc:rpc                       all 3 link-time entries removed
  flare/rpc:http (inner)              removed
  flare/net/http:http                 removed
  flare/rpc/protocol/protobuf:protobuf  4 of 7 entries removed
  flare/rpc/protocol/protobuf:baidu_std_protocol  removed
  flare/rpc/protocol/protobuf:poppy_protocol      removed

The three surviving keep_deps blocks still serve targets that DO have
non-test cross-target consumers (e.g. hbase_channel.cc directly
instantiating HbaseClientProtocol, server.cc reaching for
protobuf::Service), so privatizing their headers would break real
callers; keep_deps stays.

* BUILD: drop deps that flowed in transitively (removes last keep_deps)

The remaining keep_deps entries (after privatizing self-registration
headers) were all on umbrella targets that explicitly redeclared a
dep that one of their sub-deps had already pulled in directly. Once
that umbrella-level redundant dep is removed, the keep_deps becomes
unnecessary.

  flare/net/hbase:hbase_client       :hbase_client_protocol via :hbase_channel
  flare/net/hbase:hbase_server       :hbase_server_protocol via :hbase_service
  flare/rpc/protocol/protobuf:protobuf
                                     :service_method_locator + :rpc_meta_proto
                                     via every :*_protocol sub-dep
                                     :service is needed by flare/rpc:server,
                                     which declares the dep directly itself

After this commit, no target in the tree carries a `keep_deps`
annotation, and `blade build -p release flare/...` still reports zero
unused-dep notices.

* BUILD: restore link-time deps lost in the early dep-check cleanup

The first `BUILD: address blade dep-check notices` commit on this
branch took blade's then-noisy "Unused dependency" notices at face
value and dropped any dep whose .h didn't appear as an `#include` --
exactly the false-positive pattern that the later blade patches were
meant to fix. Two real link-time dependencies got swept up before
those patches existed:

  flare/base:compression   gzip / lz4 / snappy / zstd registrations
    SYMPTOM: MakeCompressor("GZIP") returns nullptr; the
    integration_test_{4K,64K,1M} suites crash on
    "Check failed: Compressor nullptr".

  flare/net/redis:nslb_registration   round_robin / name_resolver:list
    SYMPTOM: connecting via the `rr://` or `list://` scheme cannot
    find a registered NSLB / resolver; redis_test crashes inside
    redis_object.h:95 because the connection collapses before a
    typed reply ever arrives.

Re-add both sets of deps. The four compression implementations also
get the same self-registration treatment as the other targets touched
in this branch: `.h` -> `srcs`, `hdrs = []`, so blade auto-exempts
them from the unused-deps check without needing keep_deps.

`blade test -p release flare/... --full-test` -> 230/230 pass.

* BUILD: fix `',#pthread'` typo in thirdparty/protobuf-3.4.1

Leading comma made blade parse the dep as the malformed token
`",#pthread"` instead of the system library `#pthread`, surfacing as
\"Invalid dependency format error\" at parse time. The bug only
triggers on Linux (the `_is_linux` arm of the deps list), which is why
local macOS builds didn't catch it.

Introduced by the early dep-check cleanup commit b4806e4 when an
auto-edit regex inserted a stray separator.
2026-06-01 22:28:59 +08:00
Luo Bo f92cb6132e Always use 'lib' as libdir for cmake targets. The default one is not consistent across Linux distros. (#7) 2021-05-29 03:56:21 +08:00
Luo Bo 9cc00d3105 chore: Importing from internal repository. 2021-05-26 14:11:38 +08:00