Skip to content

[C++][FlightRPC] Fix Unity build ordering issue #49991

Description

@spotaws

Describe the bug, including details regarding any error messages, version, and platform.

When building against current grpc and protobuf, I got this failure:

/home/spot/git/sandbox/libarrow/libarrow-24.0.0-build/apache-arrow-24.0.0/cpp/src/arrow/flight/transport/grpc/grpc_client.cc: In member function ‘virtual arrow::Status arrow::flight::transport::grpc::{anonymous}::GrpcClientImpl::Init(const arrow::flight::FlightClientOptions&, const arrow::flight::Location&, const arrow::util::Uri&)’: /home/spot/git/sandbox/libarrow/libarrow-24.0.0-build/apache-arrow-24.0.0/cpp/src/arrow/flight/transport/grpc/grpc_client.cc:738:25: error: ‘FromAbslStatus’ was not declared in this scope; did you mean ‘FromGrpcStatus’? 738 | RETURN_NOT_OK(FromAbslStatus(certificate_provider->UpdateRoot(kDummyRootCert))); | ^~~~~~~~~~~~~~ /home/spot/git/sandbox/libarrow/libarrow-24.0.0-build/apache-arrow-24.0.0/cpp/src/arrow/status.h:58:45: note: in definition of macro ‘ARROW_RETURN_NOT_OK’ 58 | ::arrow::Status __s = ::arrow::ToStatus(status); \ | ^~~~~~ /home/spot/git/sandbox/libarrow/libarrow-24.0.0-build/apache-arrow-24.0.0/cpp/src/arrow/flight/transport/grpc/grpc_client.cc:738:11: note: in expansion of macro ‘RETURN_NOT_OK’ 738 | RETURN_NOT_OK(FromAbslStatus(certificate_provider->UpdateRoot(kDummyRootCert))); | ^~~~~~~~~~~~~ In file included from /home/spot/git/sandbox/libarrow/libarrow-24.0.0-build/apache-arrow-24.0.0/cpp/redhat-linux-build/src/arrow/flight/CMakeFiles/arrow_flight_objlib.dir/Unity/unity_1_cxx.cxx:25: /home/spot/git/sandbox/libarrow/libarrow-24.0.0-build/apache-arrow-24.0.0/cpp/src/arrow/flight/transport/grpc/util_internal.cc: At global scope: /home/spot/git/sandbox/libarrow/libarrow-24.0.0-build/apache-arrow-24.0.0/cpp/src/arrow/flight/transport/grpc/util_internal.cc:335:8: warning: no previous declaration for ‘arrow::Status arrow::flight::transport::grpc::FromAbslStatus(const absl::lts_20260107::Status&)’ [-Wmissing-declarations] 335 | Status FromAbslStatus(const ::absl::Status& absl_status) { | ^~~~~~~~~~~~~~

This is a Unity build (CMake UNITY_BUILD) ordering issue. The file server_tracing_middleware.cc is the first file in the Unity translation unit and includes util_internal.h without first including <grpcpp/grpcpp.h>. Since util_internal.h uses #pragma once, it's only processed once — at that point GRPC_CPP_VERSION_MAJOR is undefined, so the #if GRPC_CPP_VERSION_CHECK(1, 80, 0) guard evaluates to false and the FromAbslStatus declaration is skipped. When grpc_client.cc later tries to call FromAbslStatus, the declaration was never emitted.

(this issue pairs with my proposed fix in PR49990)

Component(s)

C++

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions