Earlier quoted context omitted.
The logic is backwards though. I may have multiple consumers of a library some of which may want static some of which may want dynamic. You need to create/import new targets to do this even though the original target creates both static and dynamic libs by default.
This is just false. Bazel creates both static and dynamic libs by default for every cc_library. The default is to link static, but you can control this on a per-binary basis. You don't need parallel trees of targets or even to write custom rules to access the non-default output groups that contain the shared library. This all just works out of the box.
What's New in Bazel 6.0
41–50 of 58 posts
Re: What's New in Bazel 6.0
#42Earlier quoted context omitted.
I don't know what you're talking about. This is trivial to accomplish using `linkstatic` as documented on `cc_library` and `cc_binary`. I uploaded a demo to github here: https://github.com/emidln/bazel_static_dynamic_c_demo/blob/m... Try it out like this: # you'll need a c compiler installed, xcode is fine on macos git clone https://github.com/emidln/bazel_static_dynamic_c_demo cd bazel_static_dynamic_c_demo bazel ru…
qux is now forced to be static. Consumers should be able to choose whatever they want. I don't know what end users want to do.
I was demonstrating that you can force some libraries to be only static and still partially link some things static and some dyanmic. If you want to get really into the weeds, you could even affect the link line and individually pick dependencies in a custom rule (that is fully compatible with the rest of the bazel tooling). Almost nobody ever needs to do that, but maybe you want to make only every other dependency dynamic to satisfy some weird slide in a talk.
Re: What's New in Bazel 6.0
#43Earlier quoted context omitted.
The logic is backwards though. I may have multiple consumers of a library some of which may want static some of which may want dynamic. You need to create/import new targets to do this even though the original target creates both static and dynamic libs by default.
This is just false. Bazel creates both static and dynamic libs by default for every cc_library. The default is to link static, but you can control this on a per-binary basis. You don't need parallel trees of targets or even to write custom rules to access the non-default output groups that contain the shared library. This all just works out of the box.
In bazel you have complete control over all of your deps. Ultimate power and ultimate responsibility. Even an external BUILD.bazel can be patched when you bring it in (bazel has provisions for patching stuff from http_archive if you supply a patch). You can even ignore an existing BUILD.bazel and write your own if you only care about part of an external thing. If it's a target in your graph, you can certainly modify it. If there is some internal process that prevents you from modifying your own code, I can't help you. Maybe fix that or go somewhere that gives you the authority to do your job.
Re: What's New in Bazel 6.0
#44Earlier quoted context omitted.
Non-Hermetic is the default for C/C++. And if you plan on using system provided libraries to support multi OSes then you can't use it.
That is precisely the point--using system-provided libraries in your Bazel project is an antipattern that should be avoided.
Re: What's New in Bazel 6.0
#45Earlier quoted context omitted.
This is just false. Bazel creates both static and dynamic libs by default for every cc_library. The default is to link static, but you can control this on a per-binary basis. You don't need parallel trees of targets or even to write custom rules to access the non-default output groups that contain the shared library. This all just works out of the box.
> You're assuming you have control over all the deps and can set `linkstatic` on them. In bazel you have complete control over all of your deps. Ultimate power and ultimate responsibility. Even an external BUILD.bazel can be patched when you bring it in (bazel has provisions for patching stuff from http_archive if you supply a patch). You can even ignore an existing BUILD.bazel and write your own if you only care abo…
That's a hack.
Re: What's New in Bazel 6.0
#46Earlier quoted context omitted.
That is precisely the point--using system-provided libraries in your Bazel project is an antipattern that should be avoided.
It's literally the default. How can the default be an anti-pattern. I doubt you're using C/C++ because you don't seem to understand the issue.
https://bazel.build/basics/hermeticity
> When given the same input source code and product configuration, a hermetic build system always returns the same output by isolating the build from changes to the host system.
> In order to isolate the build, hermetic builds are insensitive to libraries and other software installed on the local or remote host machine. They depend on specific versions of build tools, such as compilers, and dependencies, such as libraries. This makes the build process self-contained as it doesn't rely on services external to the build environment.
My overarching point is, you should fix your build rather than point blame to the tool's authors because you're using it in an unsupported way.
Re: What's New in Bazel 6.0
#47The main change here is that Bazel now has a package repository that people can pull/push external dependencies to: https://registry.bazel.build/ This is a huge change as external dependencies used to be one of the big pain points with the Bazel pipeline.
Re: What's New in Bazel 6.0
#48Earlier quoted context omitted.
That is precisely the point--using system-provided libraries in your Bazel project is an antipattern that should be avoided.
It's literally the default. How can the default be an anti-pattern. I doubt you're using C/C++ because you don't seem to understand the issue.
Re: What's New in Bazel 6.0
#49Earlier quoted context omitted.
It's literally the default. How can the default be an anti-pattern. I doubt you're using C/C++ because you don't seem to understand the issue.
Many people believe that the "traditional" way of building C/C++ applications is an antipattern. Such a belief is, in fact, a core reason to adopt bazel. If you don't believe that, then bazel may not be for you. It is intentionally opinionated in a way that you aren't.
Re: What's New in Bazel 6.0
#50Earlier quoted context omitted.
That is precisely the point--using system-provided libraries in your Bazel project is an antipattern that should be avoided.
It's literally the default. How can the default be an anti-pattern. I doubt you're using C/C++ because you don't seem to understand the issue.
Sometimes this is desirable; for example, if you are packaging for a Linux distribution. But that's not the use case Bazel was invented to serve.