3 ms·
Hermetic build systems make a lot of sense for companies, where you often want to control your whole stack and might even use a monorepo with all external depen
by bennofs 7y ago
Hermetic build systems make a lot of sense for companies, where you often want to control your whole stack and might even use a monorepo with all external dependencies vendored.
However, there are at least two cases where you do not want real hermetic builds:
- in the case of open source software that needs to be packaged for distributions, vendoring all the dependencies is bad. As the name already says, distributions remix software components and thus might want to compile your software against a different version of a library than the particular version you pick.
- for libraries, consumers use your library just as a component and might want to combine it with a specific version of other libraries, so vendoring also sucks.
Unfortunately, many declarative build systems make it hard to separate the "building a component" part from the "composing a product" part. I could find no way in Bazel to depend on system software (using for example pkgconfig).
In my opinion, build systems for open source software (as I mentioned, for companies Bazel makes sense since you often want to vendor all your deps anyway) need to have three aspects:
- build rules for just for this component
- dependencies on other components/libraries
- a method to lock down components/libraries to a specific version, creating an offical "product" with an official supported combination of all dependencies.
This still makes it possible for distributions to create their own "product", without having to rewrite most parts of the build system. At the same time, developers can work with the official library versions (for compat, maybe you should even have multiple "sets" of dependencies), so getting started is easy and you don't need to install lots of dependencies first before you can hack on the project.
Often, build systems do things that are nice for onboarding (like "build systems" that pull git repos of dependencies during build, in order to have a single command to build the product from scratch after checkout). But those things directly conflict with the needs of distributions. We need to separate the "instructions to build, supplying all deps externally explictly" (in the context of building a package for a distribution) from the "just build it from the command line on a dev machine" (here, dependencies should be implictly fetched automatically, to give a nice user experience).
- codesuki 7y agoYou could probably write a rule similar to go_repository[1] that would invoke pkgconfig to find the location of local libs instead of downloading a lib. [1] https://github.com/bazelbuild/bazel-gazelle/blob/master/internal/go_repository.bzl https://github.com/bazelbuild/bazel-gazelle/blob/master/inte...
- rienbdj 7y agopeople have done this rules_cc_foreign or something like that.
- bennofs 7y agorules_foreign_cc appears to be something different: building projects with other build systems as part of a bazel build. The README does not talk about using prebuilt system libraries at all. Additionally, adding lots of additional customization on top of the build system itself defeats the purpose of using a popular system in the first place.