p4c: Build errors with Protobuf 23
Hey,
I recently created a package of the p4 compiler for the Arch Linux User Repository: https://aur.archlinux.org/packages/p4lang-p4c
It was already a bit complicated to build it, but I eventually got it working by using CMAKE_UNITY_BUILD=ON (for some reason the compilation error-ed without it) and by specifying PROTOBUF_LIBRARY=protobuf, because it would complain about the Protobuf version or not find it while linking (see https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=p4lang-p4c#n50).
Recently, the Arch Linux developers updated protobuf from 21.12 to 23.3 (don’t ask me about these version numbers, but that seems to correspond to library version 4.23.3, while the previous one was 3.21.12). Anyway, this protobuf version depends on the abseil cpp libraries, and since CMakeLists.txt currently only links against Protobuf directly, this leaves undefined references that cause the build to fail. I found a possible solution to that problem here: https://github.com/protocolbuffers/protobuf/issues/12292#issuecomment-1529680040
By adding CONFIG to the find_package call, CMake should load the respective protobuf cmake files, which would then also link the program correctly against the abseil libraries and other possible dependencies of protobuf.
However, since adding this (and changing the version number from 3.0.0 to 23.3.0, because it complained), the build fails at the Genering protobuf dependencies step with:
[ 47%] Generating protobuf files
/bin/sh: line 1: -I: command not found
make[2]: *** [control-plane/CMakeFiles/controlplane-gen.dir/build.make:78: control-plane/google/rpc/status.pb.cc] Error 127
make[1]: *** [CMakeFiles/Makefile2:1871: control-plane/CMakeFiles/controlplane-gen.dir/all] Error 2
make: *** [Makefile:166: all] Error 2
Running make with -d for debug mode shows the following:
[ 47%] Generating protobuf files
Reaping winning child 0x561bb9b00500 PID 192167
cd /home/jkhsjdhjs/aur/p4lang-p4c/src/p4lang-p4c/build/control-plane && -I /home/jkhsjdhjs/aur/p4lang-p4c/src/p4lang-p4c/control-plane/p4runtime/proto -I/home/jkhsjdhjs/aur/p4lang-p4c/src/p4lang-p4c/control-plane --cpp_out /home/jkhsjdhjs/aur/p4lang-p4c/src/p4lang-p4c/build/control-plane --python_out /home/jkhsjdhjs/aur/p4lang-p4c/src/p4lang-p4c/build/control-plane /home/jkhsjdhjs/aur/p4lang-p4c/src/p4lang-p4c/control-plane/google/rpc/status.proto /home/jkhsjdhjs/aur/p4lang-p4c/src/p4lang-p4c/control-plane/p4runtime/proto/p4/config/v1/p4info.proto /home/jkhsjdhjs/aur/p4lang-p4c/src/p4lang-p4c/control-plane/p4runtime/proto/p4/config/v1/p4types.proto /home/jkhsjdhjs/aur/p4lang-p4c/src/p4lang-p4c/control-plane/p4runtime/proto/p4/v1/p4runtime.proto /home/jkhsjdhjs/aur/p4lang-p4c/src/p4lang-p4c/control-plane/p4runtime/proto/p4/v1/p4data.proto
Live child 0x561bb9b00500 (control-plane/google/rpc/status.pb.cc) PID 192168
/bin/sh: line 1: -I: command not found
Reaping losing child 0x561bb9b00500 PID 192168
make[2]: *** [control-plane/CMakeFiles/controlplane-gen.dir/build.make:78: control-plane/google/rpc/status.pb.cc] Error 127
Removing child 0x561bb9b00500 PID 192168 from chain.
Reaping losing child 0x55a33b04adc0 PID 192166
make[1]: *** [CMakeFiles/Makefile2:1871: control-plane/CMakeFiles/controlplane-gen.dir/all] Error 2
Removing child 0x55a33b04adc0 PID 192166 from chain.
Reaping losing child 0x55ed0f977d70 PID 192061
make: *** [Makefile:166: all] Error 2
Removing child 0x55ed0f977d70 PID 192061 from chain.
The third line shows, that the command executed if the cd command succeeds is simply -I, so I assume that some variable containing the path to some executable (maybe the protoc executable), is now no longer defined.
Do you have any idea what might be going wrong here? Thanks in advance!
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 19 (8 by maintainers)
Commits related to this issue
- Fix linking with Protobuf 23 Google introduced abseil as a new dependency of Protobuf, but CMake's FindProtobuf hasn't been updated yet to link with abseil. Thus, CMake is now advised to use the conf... — committed to jkhsjdhjs/p4c by jkhsjdhjs a year ago
- Fix linking with Protobuf 23 (#4104) Google introduced abseil as a new dependency of Protobuf, but CMake's FindProtobuf hasn't been updated yet to link with abseil. Thus, CMake is now advised to us... — committed to p4lang/p4c by jkhsjdhjs 10 months ago
I merged #4056 but will leave this one open until the CMake (or Protobuf?) package is fixed.
Protobuf has been a persistent source of pain because Google consistently introduces breaking changes. Wish we did not depend on it…
Let me check in the next couple of days. We have never tested Protobuf beyond version 21 because 22 introduces Abseil etc.
We should fix the Protobuf dependency using CMake’s FetchContent, that could get rid of a lot of these problems.