Hello gentlemen and the entire bazel world,Last two undecided issues of go/bazel-importing-precompiled-cpp-libraries are:1. --start-group --end-group support2. Separate cc_static_library_import and cc_shared_library_import vs. unified cc_importRegarding lib groups:People don't seem to shout too loudly about this, but we do have a issue on github open for a while now, and there was a stack overflow question asked about this. We have 3 options there:* No support at all at the moment, only add it when it becomes a priority. Right now it's not.* Only support lib groups for precompiled libraries. Lib groups are often a sign of suboptimal design that should be fixed in the new code, but tolerated in the legacy code. Since we are going to work on importing precompiled libraries soon, it'd be cost-effective to incorporate this into their design.* Full support. That means having some way of telling bazel that some cc_libraries should form a lib group.Personally, I'd vote against full support, for, well, the greater good. But I don't have more data and very little experience on this.
Regarding separate import rules vs single unified rule:Ulf raised a concern that people might want to import both static and shared library from the same source, and pick one depending on the properties of the build. I'm not sure how often this happens in the real world (real world please tell me :) My naive assumption was that in the majority of cases people know up front if they want to depend on static or shared library, and in the remaining cases `select` picking one of two targets will work fine. I prefer forcing users to do a little bit of more setup work to make this decision explicit, than to teaching bazel to magically pick dependencies with very different linking semantics.I'm aware that we have similar behavior with `cc_binary` and `cc_test` picking static or shared libraries for their dependencies. But that is a performance optimization, not a feature that should be used or depended on.
If you received this email it means that you're smarter than me and I hope for your advice.Cheers!----Marcel Hlopko | Software Engineer | hlo...@google.com |Google Germany GmbH | Erika-Mann-Str. 33 | 80636 München | Germany | Geschäftsführer: Geschäftsführer: Paul Manicle, Halimah DeLaine Prado | Registergericht und -nummer: Hamburg, HRB 86891
Hello gentlemen and the entire bazel world,Last two undecided issues of go/bazel-importing-precompiled-cpp-libraries are:1. --start-group --end-group support2. Separate cc_static_library_import and cc_shared_library_import vs. unified cc_importRegarding lib groups:People don't seem to shout too loudly about this, but we do have a issue on github open for a while now, and there was a stack overflow question asked about this. We have 3 options there:* No support at all at the moment, only add it when it becomes a priority. Right now it's not.* Only support lib groups for precompiled libraries. Lib groups are often a sign of suboptimal design that should be fixed in the new code, but tolerated in the legacy code. Since we are going to work on importing precompiled libraries soon, it'd be cost-effective to incorporate this into their design.* Full support. That means having some way of telling bazel that some cc_libraries should form a lib group.Personally, I'd vote against full support, for, well, the greater good. But I don't have more data and very little experience on this.
Regarding separate import rules vs single unified rule:Ulf raised a concern that people might want to import both static and shared library from the same source, and pick one depending on the properties of the build. I'm not sure how often this happens in the real world (real world please tell me :) My naive assumption was that in the majority of cases people know up front if they want to depend on static or shared library, and in the remaining cases `select` picking one of two targets will work fine. I prefer forcing users to do a little bit of more setup work to make this decision explicit, than to teaching bazel to magically pick dependencies with very different linking semantics.
On Mon, Oct 2, 2017 at 10:52 AM Marcel Hlopko <hlo...@google.com> wrote:Hello gentlemen and the entire bazel world,Last two undecided issues of go/bazel-importing-precompiled-cpp-libraries are:1. --start-group --end-group support2. Separate cc_static_library_import and cc_shared_library_import vs. unified cc_importRegarding lib groups:People don't seem to shout too loudly about this, but we do have a issue on github open for a while now, and there was a stack overflow question asked about this. We have 3 options there:* No support at all at the moment, only add it when it becomes a priority. Right now it's not.* Only support lib groups for precompiled libraries. Lib groups are often a sign of suboptimal design that should be fixed in the new code, but tolerated in the legacy code. Since we are going to work on importing precompiled libraries soon, it'd be cost-effective to incorporate this into their design.* Full support. That means having some way of telling bazel that some cc_libraries should form a lib group.Personally, I'd vote against full support, for, well, the greater good. But I don't have more data and very little experience on this.Agree with what others have said - if supported for pre-compiled libs that seems fine, and it also is probably not a priority in general, as most of these will happen within the crosstool.Regarding separate import rules vs single unified rule:Ulf raised a concern that people might want to import both static and shared library from the same source, and pick one depending on the properties of the build. I'm not sure how often this happens in the real world (real world please tell me :) My naive assumption was that in the majority of cases people know up front if they want to depend on static or shared library, and in the remaining cases `select` picking one of two targets will work fine. I prefer forcing users to do a little bit of more setup work to make this decision explicit, than to teaching bazel to magically pick dependencies with very different linking semantics.A single unified rule might also make sense from the perspective of simplicity:As a user, I'll probably in the end want to write something like:find_system_library("foo")and then depend on "@foo//foo"Many system libs come with both a static and dynamic version. Forcing people to depend one manually requires one more decision to make.One question is what our strategy for specifying which type of dependency I want is for other libraries. For example, if I want to build acc_library(name="bar", deps=["@bar//bar"], ...)and I want this to be installed as /usr/lib/libfoo.so, linking dynamically against /usr/lib/libbar.so, what will I need to write?
Similarly, if I build a binary and I want to link statically, will I need to edit my dependencies?I'm aware that we have similar behavior with `cc_binary` and `cc_test` picking static or shared libraries for their dependencies. But that is a performance optimization, not a feature that should be used or depended on.If you received this email it means that you're smarter than me and I hope for your advice.Cheers!----Marcel Hlopko | Software Engineer | hlo...@google.com |Google Germany GmbH | Erika-Mann-Str. 33 | 80636 München | Germany | Geschäftsführer: Geschäftsführer: Paul Manicle, Halimah DeLaine Prado | Registergericht und -nummer: Hamburg, HRB 86891
Hello gentlemen and the entire bazel world,Last two undecided issues of go/bazel-importing-precompiled-cpp-libraries are:1. --start-group --end-group support2. Separate cc_static_library_import and cc_shared_library_import vs. unified cc_importRegarding lib groups:People don't seem to shout too loudly about this, but we do have a issue on github open for a while now, and there was a stack overflow question asked about this. We have 3 options there:* No support at all at the moment, only add it when it becomes a priority. Right now it's not.* Only support lib groups for precompiled libraries. Lib groups are often a sign of suboptimal design that should be fixed in the new code, but tolerated in the legacy code. Since we are going to work on importing precompiled libraries soon, it'd be cost-effective to incorporate this into their design.* Full support. That means having some way of telling bazel that some cc_libraries should form a lib group.Personally, I'd vote against full support, for, well, the greater good. But I don't have more data and very little experience on this.
On Mon, Oct 2, 2017 at 4:52 AM, Marcel Hlopko <hlo...@google.com> wrote:Hello gentlemen and the entire bazel world,Last two undecided issues of go/bazel-importing-precompiled-cpp-libraries are:1. --start-group --end-group support2. Separate cc_static_library_import and cc_shared_library_import vs. unified cc_importRegarding lib groups:People don't seem to shout too loudly about this, but we do have a issue on github open for a while now, and there was a stack overflow question asked about this. We have 3 options there:* No support at all at the moment, only add it when it becomes a priority. Right now it's not.* Only support lib groups for precompiled libraries. Lib groups are often a sign of suboptimal design that should be fixed in the new code, but tolerated in the legacy code. Since we are going to work on importing precompiled libraries soon, it'd be cost-effective to incorporate this into their design.* Full support. That means having some way of telling bazel that some cc_libraries should form a lib group.Personally, I'd vote against full support, for, well, the greater good. But I don't have more data and very little experience on this.I do know of one non-legacy reason why "lib groups" of cc_library rules might be useful.Source files within a single library are often circularly-dependent, and that's generally accepted to be fine. The default behavior when searching an archive is to search all the object files within it (no ordering requirement), and thus users don't typically do anything special to get the desired linker behavior.However, in bazel, this can be problematic, because copts can only be specified for an entire "cc_library" rule at a time. If you want to specify different compilation options for different source files within a single logical library (e.g. have some sources built with copts = ["-O3"] and some not), you must split into multiple cc_library rules. But, once you do that, you've lost the implicit circular-dependency allowance, and there's now no way to express the dependencies. Of course, you didn't really want these object files to end up in two separate archives in the first place, but every cc_library turns into a separate archive whether you like it or not, and now you're stuck.Currently, people resort to using alwayslink=1 to workaround the issue, which is not ideal.Now -- even knowing of this use case, I'm not sure it's worth it to implement a solution. Even if it is worth implementing a solution, I don't think it needs to be treated together with the support for importing prebuilt .a files -- I'd say the libgroup=1 attribute for the precompiled-libs case seems fine.I could imagine supporting this use-case by introducing a new rule which takes the entire set of object-file outputs from multiple cc_library rules and turns that into one "library", or by introducing an independent "cc_source_group" rule which is just a container for sources that associates copts/features with them but doesn't actually do anything by itself.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAA2zVHp-25M2m7NYAxWqwoGwVUCZYtOWbYMV8ZGBtP7Vjwe2wQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.