-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Use the system protobuf. #7323
Use the system protobuf. #7323
Conversation
For the Mac part, we do know with certainty the location of the pkg-config file, Reviewed 7 of 7 files at r1. WORKSPACE, line 60 at r1 (raw file):
BTW Is there a technical reason for this not being simply Comments from Reviewable |
The |
Does the system protobuf on Xenial have a |
OK, that sounds fine to me. I'll rebase it to do that. About the copyright/license; the original doesn't have any copyright/license statement in it. Should we keep it as it is, should we take the license from the upstream protobuf repository (looks MIT-ish), or do something else? |
I'm slightly lost. You should use the license from wherever you copied it from. (Or if it didn't have one, we can't use it.) If https://github.com/google/protobuf/blob/master/protobuf.bzl was what you started from, then https://github.com/google/protobuf/blob/master/LICENSE would be the license. |
Sorry I wasn't clear. That's exactly where I copied from to start with. The file itself didn't have a license header, but the repository as a whole does. I didn't realize that we just ended up putting the whole LICENSE file into the |
Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. WORKSPACE, line 60 at r1 (raw file): Previously, jamiesnape (Jamie Snape) wrote…
No, not really. I could easily enough rename it to just "protobuf" if that is preferred. Comments from Reviewable |
The Xenial libprotobuf-dev package contains the headers and a pkg-config |
Yes, exactly. |
a5fa30d
to
fa5dbbd
Compare
The code that I just pushed should resolve the initial comments, with the exception of generating a cmake file as requested by @jamiesnape . I'll work on that next. |
Review status: 0 of 14 files reviewed at latest revision, 1 unresolved discussion. WORKSPACE, line 60 at r1 (raw file): Previously, clalancette (Chris Lalancette) wrote…
Actually, with the new "third_party" thing that we are doing, it can't just be called Comments from Reviewable |
Review status: 0 of 14 files reviewed at latest revision, 1 unresolved discussion. WORKSPACE, line 60 at r1 (raw file): Previously, clalancette (Chris Lalancette) wrote…
I would probably say something like Comments from Reviewable |
After looking into this, I realized that I was actually wrong in my previous answer. While libprotobuf-dev does indeed not ship with a cmake file, the package |
CMake always bundles |
Review status: 0 of 15 files reviewed at latest revision, 1 unresolved discussion. WORKSPACE, line 68 at r4 (raw file):
Should be Comments from Reviewable |
Review status: 0 of 15 files reviewed at latest revision, 1 unresolved discussion. WORKSPACE, line 68 at r4 (raw file): Previously, jamiesnape (Jamie Snape) wrote…
(also macOS, not MacOS) Comments from Reviewable |
I've just pushed a commit that does make things work on MacOS. As pointed out in the commit message, it is kind of icky because we have the same hard-code I've tried a few different things to make this nicer, but I haven't been successful with any of them:
At this point, I'm kind of out of ideas, so additional thoughts on how to make this nicer would be appreciated. |
I don't have an issue with adding the |
I'm happy to change those paths to the more stable ones. I'll do that now. Assuming we are OK with this approach, I think the last currently open request has to do with importing the newer cmake protobuf module. |
Not so happy with the Review status: 0 of 15 files reviewed at latest revision, 1 unresolved discussion. Comments from Reviewable |
Review status: 0 of 15 files reviewed at latest revision, 1 unresolved discussion. WORKSPACE, line 68 at r4 (raw file): Previously, jamiesnape (Jamie Snape) wrote…
Done. Comments from Reviewable |
I'm not really that happy with it either. I'll tinker around some more and see if I can do something better. Review status: 0 of 15 files reviewed at latest revision, 1 unresolved discussion. Comments from Reviewable |
Would it be less painful to support the latest protobuf on Mac? Do we need compatibility between Mac protobufs and Linux protobufs? |
Yeah, I think it would be. If we just supported the latest protobuf, I don't think we'd have to munge the PATH at all in
The one area of concern here is that protobuf is being used to store "configuration" data out to disk. The question is whether that data is wire-compatible between version 2 and version 3, given that we are explicitly specifying version 2 in the |
You would not need that either. The |
Got it.
After going over how protobuf is used more carefully, in all cases except for the Matlab RPC, we are using the "text" representation of protobufs. We know that this works in both protobuf 2 and protobuf 3 because both the master branch and this branch pass tests. This leaves the matlab RPC question. After doing some testing there, it looks like protoc version 2, compiling syntax 2, and protoc version 3, compiling syntax 2, both output the same on-the-wire format. For comparison, protoc version 3, compiling syntax 3, outputs a slightly different on-the-wire format. Thus, I think things will remain compatible, even if macOS and Xenial are on different versions. Assuming there is no other objection to them having different versions, I will change this patch up to use the "default" protobuf package on macOS, which gets rid of a lot of the nastiness. This will unfortunately require another change to |
OK, so the latest goes back to using whatever "default" macOS has installed. I was not able to test it on macOS yet, but I should be getting a Mac in the mail tomorrow. @soonho-tri If you have time to run the compile and tests on this branch today, that would be helpful, but if not, I'll do the testing tomorrow. Now that I think we are mostly in agreement on that, I'll look into importing the cmake file that @jamiesnape suggested. |
If you update |
@clalancette, I'll do it this evening. |
Review status: all files reviewed at latest revision, 9 unresolved discussions. tools/workspace/protobuf/find_protobuf_cmake.BUILD.bazel, line 15 at r41 (raw file): Previously, EricCousineau-TRI wrote…
BTW All files that we would add here would come from CMake 3.10 or earlier, so the Copyright.txt would always be the same file from CMake. CMakeLists.txt, line 78 at r33 (raw file): Previously, jamiesnape (Jamie Snape) wrote…
Also, thinking about it Comments from Reviewable |
Review status: all files reviewed at latest revision, 7 unresolved discussions. tools/skylark/drake_cc.bzl, line 398 at r41 (raw file): Previously, EricCousineau-TRI wrote…
OK Yes, this code is definitely being run (libdrake.so, as well as pybind.bzl, use it with linkshared = 1). tools/workspace/which.bzl, line 26 at r41 (raw file): Previously, EricCousineau-TRI wrote…
What's the thought process? If name and command are identical, then there would be no change. If they differ, to my thinking having the label match the command name like Comments from Reviewable |
Review status: 17 of 18 files reviewed at latest revision, 8 unresolved discussions. setup/ubuntu/16.04/install_prereqs.sh, line 100 at r41 (raw file): Previously, EricCousineau-TRI wrote…
The changes to use patchelf only happen on Linux, so we don't need it on macOS. third_party/com_github_google_protobuf/BUILD.bazel, line 1 at r41 (raw file): Previously, EricCousineau-TRI wrote…
Sorry, I'm not sure I understand which 'provenance file' you are talking about. Can you elaborate? tools/install/install.py.in, line 191 at r41 (raw file): Previously, EricCousineau-TRI wrote…
Ah, much nicer. Changed to that now; thank you! tools/skylark/drake_cc.bzl, line 414 at r40 (raw file): Previously, jwnimmer-tri (Jeremy Nimmer) wrote…
Fixed now. tools/skylark/drake_cc.bzl, line 398 at r41 (raw file): Previously, EricCousineau-TRI wrote…
I've tested this locally (on both Linux and macOS), and it seems to work on CI (with the exception of known bad tests failing). Also, if this wasn't doing the right thing, then we know for sure that the MATLAB tests would crash. So I'm fairly confident this works. CMakeLists.txt, line 78 at r33 (raw file): Previously, jamiesnape (Jamie Snape) wrote…
@jamiesnape I think your last comment got cut-off; was there a change that you would like to see here? Comments from Reviewable |
Review status: 17 of 18 files reviewed at latest revision, 7 unresolved discussions. CMakeLists.txt, line 78 at r33 (raw file): Previously, clalancette (Chris Lalancette) wrote…
I honestly forget now, but I think we good in the current iteration. Comments from Reviewable |
Review status: 17 of 18 files reviewed at latest revision, 6 unresolved discussions. third_party/com_github_google_protobuf/BUILD.bazel, line 1 at r41 (raw file): Previously, clalancette (Chris Lalancette) wrote…
In this directory, some files are copyright Google, and some files are copyright Drake. Eric is asking for that distinction to be made clearer. The second part was about making it clear that the origin commit of protobuf.bzl is in its git history. I guess some people expect a file in this directory to have breadcumbs, rather than just git log. (I always just use git log myself.) Probably a short README.md would meet both needs. Comments from Reviewable |
Reviewed 1 of 1 files at r42. Comments from Reviewable |
Review status: 18 of 19 files reviewed at latest revision, 5 unresolved discussions. third_party/com_github_google_protobuf/BUILD.bazel, line 1 at r41 (raw file): Previously, jwnimmer-tri (Jeremy Nimmer) wrote…
I added a README now. Comments from Reviewable |
BTW Chris, you may have introduced blocking comments through your responses. If you prefix it with Reviewed 1 of 1 files at r42, 1 of 1 files at r43. tools/workspace/which.bzl, line 26 at r41 (raw file): Previously, jwnimmer-tri (Jeremy Nimmer) wrote…
The request was for accuracy; if the user for some reason specifies a
Comments from Reviewable |
tools/workspace/which.bzl, line 26 at r41 (raw file): Previously, EricCousineau-TRI wrote…
If the user does name = foo, command = bar, then tey get Comments from Reviewable |
Review status: all files reviewed at latest revision, 2 unresolved discussions. tools/workspace/which.bzl, line 26 at r41 (raw file): Previously, jwnimmer-tri (Jeremy Nimmer) wrote…
Ah, no, that was me misunderstanding. (Also, at some point, it'd be nice to have this get multiple commands, so I could use it something like Comments from Reviewable |
Reviewed 1 of 1 files at r43. tools/workspace/which.bzl, line 26 at r41 (raw file): Previously, EricCousineau-TRI wrote…
Great, I'd support Comments from Reviewable |
pending final discussion points. Everything worked per this PR. Note: Seems like the installed
However, this behavior happens on Review status: all files reviewed at latest revision, 2 unresolved discussions. Comments from Reviewable |
Taken from https://github.com/google/protobuf/blob/4fc9304/protobuf.bzl Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
This means using both the system version of the protoc compiler and the system libprotobuf.so to link against. To do this, we use the pristine version of protobuf.bzl file from upstream protobuf, and modify it to use "command" instead of "executable" to run protoc. We then use pkg-config to find the libprotobuf.so flags as appropriate. The combination of all of this seems to make things work properly. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
The comment in the code explains why. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
b266404
to
bf3bad0
Compare
Review status: 16 of 19 files reviewed at latest revision, 2 unresolved discussions. tools/workspace/which.bzl, line 26 at r41 (raw file): Previously, jwnimmer-tri (Jeremy Nimmer) wrote…
I've changed the language to use As far as the aliasing Comments from Reviewable |
Review status: 16 of 19 files reviewed at latest revision, 2 unresolved discussions. a discussion (no related file): Previously, jwnimmer-tri (Jeremy Nimmer) wrote…
I've now rebased this onto master, and squashed everything down to 3 different commits (the original pristine protobuf.bzl, the local changes, and then the changes to make sure RPATH works). That seemed to make sense to me, but let me know if you want me to squash it down into 2 again. Comments from Reviewable |
pending CI. (Before merge, we should opt-in to macOS builds.) Reviewed 3 of 3 files at r44. a discussion (no related file): Previously, clalancette (Chris Lalancette) wrote…
SGTM. Comments from Reviewable |
@drake-jenkins-bot mac-highsierra-clang-bazel-experimental-everything please |
Review status: all files reviewed at latest revision, 1 unresolved discussion. tools/workspace/which.bzl, line 26 at r41 (raw file): Previously, clalancette (Chris Lalancette) wrote…
Sorry, that was just me mixing my confusion with using As is, it is now clear that modifying Comments from Reviewable |
The macOS failures were caused by something else, and were fixed by 96d1681 . So they can safely be ignored in this PR. |
Agreed. Merging now. |
This means using both the system version of the protoc compiler
and the system libprotobuf.so to link against. To do this,
we copy a version of the protobuf.bzl file from upstream protobuf,
and modify it to use "command" instead of "executable" to run
protoc. We then use pkg-config to find the libprotobuf.so
flags as appropriate. The combination of all of this seems
to make things work properly.
This is the third part of #7278 , and makes things work properly on Linux. This PR should be considered an RFC, because I know for a fact that it does not work as-is on MacOS. I was able to make MacOS work by manually doing
export PKG_CONFIG_PATH=/usr/local/Cellar/protobuf@2.6/2.6.0/lib/pkgconfig
and by changing$(which protoc)
to/usr/local/Cellar/protobuf@2.6/2.6.0/bin/protoc
ontools/skylark/drake_proto.bzl
, but those are obviously hacks. I'm looking for some advice on how to make this work for MacOS, and possibly get a login for a MacOS machine to continue debugging (I lost access to the one I was using).This change is