-
Notifications
You must be signed in to change notification settings - Fork 444
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
Build errors with Protobuf 23 #4055
Comments
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. |
Exactly :) In other project I have quite good experience with ExternalProject_Add / FetchContent and fixed version of Protobuf. |
Is this project public? Do you build from scratch or do you use prebuilt binaries? I'd prefer the latter since protobuf is big and slow to build... |
Not a public one. We use prebuilt binaries as well, good direction :) |
Were do you get prebuilt libprotobuf(-lite) files from? Iirc they are not supplied with the Github zips for some reason. |
Well yeah, we build it manually (not only protobuf..) and store prebuilt libraries. Maybe p4c could follow same steps.. |
@jkhsjdhjs Could you try this PR #4056 to check whether it helps your case? |
@fruffy Thanks for your work on this! I just tested it, and it builds fine using the downloaded protobuf version. I did see 2 CMake warnings though:
If I try to install the build package however, I see that the package including protobuf is 80MB larger than without it, and that the included protobuf files currently conflict with the system protobuf:
Not sure what can be done about that. Because I'd prefer using the system protobuf anyway, I also tried building with 21.12 installed and
Even if I remove the version requirement entirely, it still doesn't work:
This can be worked around my adding I also have a feeling it would work with Protobuf 23, since the only problem I had was linking with abseil. But I can understand if you don't wanna work on this, it really is a PITA. |
Great to hear the FetchContent version builds. I believe the warnings come from newer version of CMake. They are easy to fix but older versions may complain. This looks like a CMake<-->Arch problem to me. I am unsure how This is hard to fix since I currently do not run Arch. How does the package conflict happen, are you running |
Yeah, you're right.
Yep, happens with a clean CMake cache. I just ran cmake with
Bascially what I'm doing is creating a package from the |
I think this is fixable but the workaround is a little awkward.
Great, are you able to build P4C now?
I see, I did not consider that. Maybe it is possible to choose separate install path for the local P4C version. |
I can build it with Protobuf 21.12 without the
Would be great! |
I was able to get Protobuf 23 to build with the FetchContent setup, but it is finicky. The Protobuf/Abseil CMake installation still seems a bit broken. So I would prefer to keep things below 22.x for now. Although at some point we definitely have to migrate.
Okay, let me look into that. |
@jkhsjdhjs I pushed a new commit that (hopefully) excludes Protobuf from the |
Yep, that works, thanks for your work on this! Since all the executables are now quite a bit larger, I assume the protobuf library is now baked directly into them, right? BTW: Did you do anything special to build p4c with protobuf 23? If not, this may as well be an issue with the protobuf installation on Arch Linux. In this case I might check back with the Arch Linux developers in the next days and see if they have an idea what might be going on. |
Yes, a lot of the compiler libraries including Protobuf are linked statically. Although I am surprised this was not the case before here.
Iirc no. I checked out the version on Github and built it by adding Protobuf as a CMake subdirectory. I had to add the includes/libraries manually, but that's it. I think this issue is very much related, maybe CMake is simply broken here? |
Ah, this is probably done to keep the binaries as portable as possible or to avoid issues with breaking changes of dependencies. Also regarding that: Currently, this repository already has three submodules. If protobuf is compiled from source anyway, wouldn't it make sense to add that as a submodule as well, instead of downloading it via CMake? This way, the build would not requiring internet access, and keep the dependency management consistent with the other dependencies.
Yeah, that's the issue I also linked. A comment there suggests to add |
There is actually a PR to consolidate these submodules: #3970
Hmm, it looks like there is no clear fix available right now. This might require some trial and error. |
I merged #4056 but will leave this one open until the CMake (or Protobuf?) package is fixed. |
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 config provided by Protobuf instead of its own. In case no config can be found, we fall back to the old behavior. The Protobuf version constraint is removed since it only applies with `P4C_USE_PREINSTALLED_PROTOBUF=ON` anyway, in which case we'll want to use whatever preinstalled version is available. Furthermore, the variables `PROTOBUF_LIBRARY` and `PROTOBUF_PROTOC_EXECUTABLE` are set correctly so executing `protoc` and linking with Protobuf doesn't fail. Fix p4lang#4055 See also protocolbuffers/protobuf#12292
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 config provided by Protobuf instead of its own. In case no config can be found, we fall back to the old behavior. The Protobuf version constraint is removed since it only applies with `P4C_USE_PREINSTALLED_PROTOBUF=ON` anyway, in which case we'll want to use whatever preinstalled version is available. Furthermore, the variables `PROTOBUF_LIBRARY` and `PROTOBUF_PROTOC_EXECUTABLE` are set correctly so executing `protoc` and linking with Protobuf doesn't fail. Fix #4055 See also protocolbuffers/protobuf#12292
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 specifyingPROTOBUF_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: protocolbuffers/protobuf#12292 (comment)
By adding
CONFIG
to thefind_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:Running make with
-d
for debug mode shows the following: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!
The text was updated successfully, but these errors were encountered: