trpc-group / trpc-cpp

A pluggable, high-performance RPC framework written in cpp
Other
270 stars 78 forks source link

编译报错'GetArenaForAllocation' was not declared in this scope #170

Closed yayawcx closed 1 month ago

yayawcx commented 1 month ago

bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2881:64: error: there are no arguments to 'GetArenaForAllocation' that depend on a template parameter, so a declaration of 'GetArenaForAllocation' must be available [-fpermissive] 2881 | impl.caller_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); | ^~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: In member function 'void trpc::RequestProtocol::_internal_set_caller(const string&)': bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2894:29: error: 'GetArenaForAllocation' was not declared in this scope 2894 | impl.caller_.Set(value, GetArenaForAllocation()); | ^~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: In member function 'std::string trpc::RequestProtocol::_internal_mutable_caller()': bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2898:33: error: 'GetArenaForAllocation' was not declared in this scope 2898 | return impl.caller_.Mutable(GetArenaForAllocation()); | ^~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: At global scope: bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2900:21: error: no declaration matches 'std::string trpc::RequestProtocol::release_caller()' 2900 | inline std::string RequestProtocol::release_caller() { | ^~~~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2900:21: note: no functions named 'std::string trpc::RequestProtocol::release_caller()' bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:1463:7: note: 'class trpc::RequestProtocol' defined here 1463 | class RequestProtocol final : | ^~~~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: In member function 'void trpc::RequestProtocol::set_allocated_caller(std::string)': bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2910:39: error: 'GetArenaForAllocation' was not declared in this scope 2910 | impl.caller_.SetAllocated(caller, GetArenaForAllocation()); | ^~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: In member function 'void trpc::RequestProtocol::set_callee(ArgT0&&, ArgT ...)': bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2931:17: error: 'struct google::protobuf::internal::ArenaStringPtr' has no member named 'SetBytes' 2931 | impl.callee_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); | ^~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2931:64: error: there are no arguments to 'GetArenaForAllocation' that depend on a template parameter, so a declaration of 'GetArenaForAllocation' must be available [-fpermissive] 2931 | impl.callee_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); | ^~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: In member function 'void trpc::RequestProtocol::_internal_set_callee(const string&)': bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2944:29: error: 'GetArenaForAllocation' was not declared in this scope 2944 | impl.callee_.Set(value, GetArenaForAllocation()); | ^~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: In member function 'std::string trpc::RequestProtocol::_internal_mutable_callee()': bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2948:33: error: 'GetArenaForAllocation' was not declared in this scope 2948 | return impl.callee_.Mutable(GetArenaForAllocation()); | ^~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: At global scope: bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2950:21: error: no declaration matches 'std::string trpc::RequestProtocol::release_callee()' 2950 | inline std::string RequestProtocol::release_callee() { | ^~~~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2950:21: note: no functions named 'std::string trpc::RequestProtocol::release_callee()' bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:1463:7: note: 'class trpc::RequestProtocol' defined here 1463 | class RequestProtocol final : | ^~~~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: In member function 'void trpc::RequestProtocol::set_allocated_callee(std::string)': bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2960:39: error: 'GetArenaForAllocation' was not declared in this scope 2960 | impl.callee_.SetAllocated(callee, GetArenaForAllocation()); | ^~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: In member function 'void trpc::RequestProtocol::set_func(ArgT0&&, ArgT ...)': bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2981:15: error: 'struct google::protobuf::internal::ArenaStringPtr' has no member named 'SetBytes' 2981 | impl.func_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); | ^~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2981:62: error: there are no arguments to 'GetArenaForAllocation' that depend on a template parameter, so a declaration of 'GetArenaForAllocation' must be available [-fpermissive] 2981 | impl.func_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); | ^~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: In member function 'void trpc::RequestProtocol::_internal_set_func(const string&)': bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2994:27: error: 'GetArenaForAllocation' was not declared in this scope 2994 | impl.func_.Set(value, GetArenaForAllocation()); | ^~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: In member function 'std::string trpc::RequestProtocol::_internal_mutable_func()': bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:2998:31: error: 'GetArenaForAllocation' was not declared in this scope 2998 | return impl.func_.Mutable(GetArenaForAllocation()); | ^~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: At global scope: bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:3000:21: error: no declaration matches 'std::string trpc::RequestProtocol::release_func()' 3000 | inline std::string RequestProtocol::release_func() { | ^~~~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:3000:21: note: no functions named 'std::string trpc::RequestProtocol::release_func()' bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:1463:7: note: 'class trpc::RequestProtocol' defined here 1463 | class RequestProtocol final : | ^~~~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: In member function 'void trpc::RequestProtocol::set_allocated_func(std::string)': bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:3010:35: error: 'GetArenaForAllocation' was not declared in this scope 3010 | impl.func_.SetAllocated(func, GetArenaForAllocation()); | ^~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: In member function 'void trpc::ResponseProtocol::set_error_msg(ArgT0&&, ArgT ...)': bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:3246:20: error: 'struct google::protobuf::internal::ArenaStringPtr' has no member named 'SetBytes' 3246 | impl.errormsg.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); | ^~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:3246:67: error: there are no arguments to 'GetArenaForAllocation' that depend on a template parameter, so a declaration of 'GetArenaForAllocation' must be available [-fpermissive] 3246 | impl.errormsg.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); | ^~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: In member function 'void trpc::ResponseProtocol::_internal_set_error_msg(const string&)': bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:3259:32: error: 'GetArenaForAllocation' was not declared in this scope 3259 | impl.errormsg.Set(value, GetArenaForAllocation()); | ^~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: In member function 'std::string trpc::ResponseProtocol::_internal_mutable_error_msg()': bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:3263:36: error: 'GetArenaForAllocation' was not declared in this scope 3263 | return impl.errormsg.Mutable(GetArenaForAllocation()); | ^~~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: At global scope: bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:3265:21: error: no declaration matches 'std::string trpc::ResponseProtocol::release_error_msg()' 3265 | inline std::string ResponseProtocol::release_error_msg() { | ^~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:3265:21: note: no functions named 'std::string trpc::ResponseProtocol::release_error_msg()' bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:1788:7: note: 'class trpc::ResponseProtocol' defined here 1788 | class ResponseProtocol final : | ^~~~ bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h: In member function 'void trpc::ResponseProtocol::set_allocated_error_msg(std::string)': bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h:3275:45: error: 'GetArenaForAllocation' was not declared in this scope 3275 | impl.errormsg.SetAllocated(error_msg, GetArenaForAllocation()); | ^~~~~ INFO: Elapsed time: 173.612s, Critical Path: 17.64s INFO: 4961 processes: 3082 internal, 1879 linux-sandbox. ERROR: Build did NOT complete successfully

环境: $ uname -m x86_64

$ uname -r 5.10.25-nvidia-gpu

$ cat /etc/os-release PRETTY_NAME="Ubuntu 22.04 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy

$ bazel --version bazel 7.2.1

$ pkg-config --modversion protobuf 3.15.8

$ protoc --version libprotoc 3.15.8

$ gcc --version gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

编译不通过,一直报错如上错误,请问这是什么原因?

weimch commented 1 month ago

protobuf版本不对,可以检查下生成的桩代码文件的最上面,看下是否是期望的protobuf版本所编译的

bazel-out/k8-fastbuild/bin/external/com_github_trpc_protocol/trpc/trpc.pb.h

weimch commented 1 month ago

When using cc_proto_library, bazel will use a specific version of protobuf to generate .pb.h/.pb.cc stub code.

Starting from bazel-7, we can't change version of protobuf by simply declare a com_google_protobuf bazel repository (it does work in bazel-1~bazel-6). So the stub code will be genreated using protobuf-3.21.8 and can't compatible with trpc-cpp protobuf-3.15.8 which causes compile error.

To resolve this problem, just downgrade bazel version to bazel-6.