fbthrift icon indicating copy to clipboard operation
fbthrift copied to clipboard

Rust `thriftclient` missing (required by sapling/eden and buck2)

Open ben-- opened this issue 8 months ago • 0 comments

In working to get the edenfs linux build (and then Mononoke) working in OSS sapling, I've run into some missing components:

1. make_*Service_thriftclient! macro

This macro is referenced in several places in the Sapling codebase:

~/oss/sapling$ rg --sort=path make_.*_thriftclient
eden/fs/cli_rs/edenfs-client/src/client/connector.rs
19:use thrift_streaming_thriftclients::make_StreamingEdenServiceExt_thriftclient;
113:            let client: StreamingEdenFsThriftClient = make_StreamingEdenServiceExt_thriftclient!(

eden/mononoke/modern_sync/src/commands/benchmark/stats.rs
20:use fb303_core_thriftclients::make_BaseService_thriftclient;
135:    make_BaseService_thriftclient!(

eden/mononoke/scs/raw_client_lib/src/lib.rs
263:        use source_control_thriftclients::make_SourceControlService_thriftclient;
275:        let client = make_SourceControlService_thriftclient!(

and, internally, it appears they are created by (or accessed through) BUCK targets like these:

~/oss/sapling$ rg --sort=path 'rust-(thrift)?clients'
eden/fs/cli_rs/edenfs-client/BUCK
67:        "//eden/fs/service:thrift-streaming-rust-clients",
68:        "//eden/fs/service:thrift-streaming-rust-thriftclients",

eden/mononoke/modern_sync/BUCK
60:        "//fb303/thrift:fb303_core-rust-thriftclients",

eden/mononoke/scs/raw_client_lib/BUCK
16:                "//eden/mononoke/scs/if:source_control-rust-thriftclients",
23:                "//eden/mononoke/scs/if:source_control-rust-thriftclients",
34:        "//eden/mononoke/scs/if:source_control-rust-clients",

which appear to be created by the (internal only) thrift_library() bzl macro:

~/oss/sapling$ rg -A1 'thrift_library' -g BUCK
eden/fs/service/BUCK
475:thrift_library(
476-    name = "thrift",
--
502:thrift_library(
503-    name = "thrift-streaming",

fb303/thrift/BUCK
19:thrift_library(
20-    name = "fb303_core",

eden/mononoke/scs/if/BUCK
6:thrift_library(
7-    name = "source_control",

I've been able to reconstruct functionality equivalent to the *-rust-clients BUCK targets by having CMake call the autocargo-generated thrift_build.rs stubs. However, I haven't found a way to generate the make_*_thriftclients!() Rust macros that appear to be created by (or accessed throug) the *-rust-thriftclients BUCK targets.

2. The thriftclient implementation:

In trying to reverse engineer the make_*_thriftclients!() macro, I've found some symbols (e.g. ::thriftclient::ThriftChannelBuilder) referenced in buck2, sapling, and fbthrift that seem to point to the following BUCK target:

It seems that some of the broken dependencies in the OSS build might be fixed if fbthrift or rust-shed included this module.

~/oss/sapling$ rg bareclient:thriftclient -g BUCK
eden/scm/lib/cas-client/thin-client/BUCK
26:        "//common/rust/thrift/bareclient:thriftclient",

eden/mononoke/git/facebook/scs_connection/BUCK
14:        "//common/rust/thrift/bareclient:thriftclient",

eden/mononoke/common/facebook/thrift_client/BUCK
16:        "//common/rust/thrift/bareclient:thriftclient",

ben-- avatar Jul 16 '25 17:07 ben--