Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#35922 protobuf_generate_grpc_cpp_with_import_path_correction BUG #37955

Open
zgjja opened this issue Oct 19, 2024 · 0 comments
Open

#35922 protobuf_generate_grpc_cpp_with_import_path_correction BUG #37955

zgjja opened this issue Oct 19, 2024 · 0 comments

Comments

@zgjja
Copy link

zgjja commented Oct 19, 2024

What version of gRPC and what language are you using?

Tried "master" and "v1.67.0" with C++

What operating system (Linux, Windows,...) and version?

Linux, Ubuntu22.04

What runtime / compiler are you using (e.g. python version or version of gcc)

gcc11.4.0

What did you do?

I want to build absl, Protobuf, and grpc statically by FetchContenet_Declare , Now i face the issue as #35922 said. I can provide more details:

  1. The grpc trying to get the _gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR from libprotoc
  2. since libprotoc link libprotobuf, and the libprotobuf do:
target_include_directories(libprotobuf PUBLIC
  $<BUILD_INTERFACE:${protobuf_SOURCE_DIR}/src>
  $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
  1. Now _gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR is a "generator expression"
  2. The protobuf_generate_grpc_cpp_with_import_path_correction in CMakeLists.txt will get that:
function(protobuf_generate_grpc_cpp_with_import_path_correction FILE_LOCATION IMPORT_PATH)
  if(NOT FILE_LOCATION)
    message(SEND_ERROR "Error: PROTOBUF_GENERATE_GRPC_CPP() called without any proto files")
    return()
  endif()

  # Sets the include path for ProtoBuf files
  set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR})
...
  1. Now the _gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR is a "list", with "INSTALL_INTERFACE" an empty string, cause all the protobuf_generate_grpc_cpp_with_import_path_correction call fails

What did you expect to see?

The _gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR should be a single dir or list without any empty string.

What did you see instead?

In my case, this WRONG cmake command would be:

cd /xxx/Debug/protos && /xxx/build/Debug/_deps/protobuf-build/protoc-28.2.0 --grpc_out=generate_mock_code=true:/xxx/build/Debug/gens --cpp_out=/xxx/build/Debug/gens --plugin=protoc-gen-grpc=/xxx/build/Debug/_deps/grpc-build/grpc_cpp_plugin -I . -I /xxx/Debug/_deps/protobuf-src/src "" src/proto/grpc/channelz/channelz.proto

the complain from protoc:

You seem to have passed an empty string as one of the arguments to /xxx/build/Debug/_deps/protobuf-build/protoc-28.2.0.  This is actually sort of hard to do.  Congrats.  Unfortunately it is not valid input so the program is going to die now.

Anything else we should know about your project / environment?

  1. Protobuf version: v5.28.2, absl is from "master"
  2. CMake version: 3.30
  3. I use FetchContenet_Declare for all 3 projects and set all dependencies for grpc as "package"
@zgjja zgjja changed the title #35922 not solved yet #35922 protobuf_generate_grpc_cpp_with_import_path_correction BUG Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants