-
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 version of protobuf #7278
Conversation
FYI The For the rest, we should probably first do a short design review to agree on the overall approach, and then work the changes into separate PRs. For example, some the C++ refactoring could probably go in first. |
The default CI builders use a pre-built AMI image and ignore the |
Sure, sounds good. What's the usual procedure for doing a design review? @stonier should be involved as well. |
We've already discussed the approach in email, so I think we're already mostly aligned. I was unsure whether there were any further PR-spanning caveats that we should address up-front, given the code now on the table, but after a quick skim I think it will be OK to address it chunk-wise, so I say we can skip any more pre-review phases. I see at least these changes mixed into this PR:
I think each of those items could be its own PR, filed one at a time (waiting for the prior step to merge before opening the next one)? We could still keep this PR open (labeled as "status: do not review") with the full set of commits for design reference and CI feedback on the end goal. I have seen that workflow do well for large changes. It should help focus review on each piece, without letting, e.g., the debate on Step (5) get in the way of Step (2), and allowing for the most appropriate reviewers for each step to be assigned the review. Would a plan like that work for you? Another reason I suggest breaking it up is that, per email, I am still not on board with Step (6). I think in the medium term, either we drop the code in question from the install entirely, or we install it as part of In any case, I think the most immediate next step is to rebase this PR onto the latest master, so that it can be run in CI, then ask the bot to run an unprovisioned Ubuntu build to prove it passes in final form, and then we can get Step (1) merged so that CI is ready for whatever comes next. |
That sounds reasonable to me. I'm going to leave this open as you mention for reference purposes, and I'll start opening smaller PRs with the various pieces. |
I had another realization: in terms of evidence for what packages shall be needed for CI, so that we can merge the |
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. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
The point of this is to make sure that no symbols from libprotobuf are needed or exported by libdrake.so. That way, the core of libdrake.so just has objects, and they can be optionally populated by protobuf by linking against an additional library called libdrake-loader.so. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
44ef097
to
68aac7a
Compare
@clalancette Should this PR, a prior draft of the protobuf changes, be closed now? |
The only reason to keep this one open would be because of point 2 in the initial comment (basically, splitting libdrake.so up so it has a loader section). We don't have a PR for that (or agreement on that way forward, for that matter), so if you don't think we need to track that for now, I'm fine with closing it. |
Thanks, I'd forgotten about that. If you want to leave open for that reason, that's fine by me. |
PR #7323 went in now, letting us use the system protobuf library and doing the first of the two things this original PR did. The second part of this PR was splitting |
Short story - I'm fine with closing this one out here. We can shelve the loader module to do 'as needed'. If there's a plan to modularise the drake libraries which has been recently discussed, then may be a good time to re-raise the issue in advance. |
Sounds good. Closing this out (but keeping the branch around on the OSRF fork). |
Having an internal copy of protobuf linked to
libdrake.so
is problematic for external users. There are 2 major problems:libdrake.so
and link against a different version of protobuf, the symbols will collide and cause havoc.bazel run //:install
installs the internal protobuf headers, anything trying to build against thelibdrake.so
headers will automatically get a newer version of protobuf headers, which they may not want.To fix the above problems, this fairly large PR does two major things:
It changes drake to use the system version of protobuf instead of a WORKSPACE downloaded version. In particular, on Ubuntu 16.04, this will use the system versions of protobuf 2.6 instead of the downloaded 3.1 that was being used before. This is made to work by copying
protobuf.bzl
from the upstream protobuf project (https://github.com/google/protobuf/blob/master/protobuf.bzl), and modifying it. The modifications mostly consist of renaming the rules to becc_sysproto_library
andpy_sysproto_library
, as well as changing how protoc gets found by usingcommand
in thectx.action
instead ofexecutable
. Once that is in place, we then have to modify the.proto
files throughout the tree to make them protobuf-2 compatible (as a side-note, protobuf-3 can also generate code for these protobuf-2 style.proto
files, so this should be compatible into the future).It splits out any components of
libdrake.so
that contained protobuf symbols. The thinking here is thatlibdrake.so
will impose no protobuf on a user that wants to link against it. In order to do this, anything that directly depends on protobuf gets pushed out to alibdrake-loader.so
, which does depend on protobuf. This was accomplished by creating factory functions for the two places that do actually use protobuf;RigidBodyAliasTreeGroupsLoadFromFile
andParamSetLoadFromFile
. These two factory functions create an object (RigidBodyTreeAliasGroups
andParamSet
, respectively), populate it from the protobuf file being passed in, and then return that object as astd::unique_ptr
. Consumers of this can then use the unique_ptr or trivially convert it to a shared_ptr at their convenience. Note that the patch that implements all of the above is larger than might be assumed because I had to push the object passing up through several layers to split it out properly.A few of things to note:
libprotobuf-dev
andprotobuf-compiler
) and one new package on MacOS (protobuf@2.6
).This change is