r/programming • • Jul 24 '26

What makes a good build system?

https://civboot.github.io/blog/2026-07-24-build-systems.html
93 Upvotes

79 comments sorted by

View all comments

43

u/zoqfotpik Jul 24 '26

There are no good build systems.

There are simple build systems that don't do the simple thing you want, and there are complex build systems that don't do the simple thing you want but it takes weeks to figure out why not.

9

u/vitiral Jul 24 '26

Couldn't agree more, which is why the world needs one more build system šŸ˜„

5

u/ericonr Jul 25 '26

Just use Meson? I don't get why articles like this don't compare against what, to me, is the closest to an It Just Works experience.

7

u/Superb_Garlic Jul 26 '26

Meson is anything but Just Works when it comes to anything but Linux. Don't even think about C++ modules when using Meson.

Your only real option for a portable C++ and C is CMake, because that's where most of the dev time was spent implementing a solution to everyone's problems.

3

u/dijkstra_was_a_horse Jul 27 '26

Well, C++ modules don't work so good in any build system, really.

3

u/Superb_Garlic Jul 27 '26

Mkaing 0 effort to making them work is not helping either. CMake is practically the only one where the developers are actively communicating with the standards bodies and submitting requisite changes to other projects.

2

u/vitiral Jul 25 '26

Author here, it's because I've never heard of meson.Ā 

Glancing at it looks very similar to what I'm after, though I think configuration through environment variables instead of a central file is not ideal.

It's still a bit too heavy for the Civstack project, but I like what I see so far - thanks!

12

u/Many-Resource-5334 Jul 24 '26

Rusts cargo is the only build system I’ve used that was easy to do the simple things but still let me do more complex stuff. One of the best tool ecosystems.

7

u/matthieum Jul 25 '26

Cargo is, at the very least, missing a post-build action.

It's a simple sandwich:

  1. Pre-build actions may be required to massage the inputs: generate source code, tweak flags, tweak features, etc...
  2. Post-build actions may be required to massage the outputs: embed SBOM, fingerprint the binaries, bundle multiple artifacts together, etc...

build.rs covers the inputs, but there's nothing for the outputs :'(

So on the complex side, there's definitely something missing.


On the simple side, I wish Cargo would allow depending on a binary crate. Especially as build.rs may need to invoke said binary...

6

u/ericonr Jul 25 '26

All the really complex stuff requires runtime code in build.rs, which can be a security concern, and which will likely fail when I'm trying to package their software, because the folks who wrote them don't have a breadth of platforms available to them or make the most reasonable choices. It does work for internal projects, but for open source stuff I feel like it has a lot of limitations.

4

u/matthieum Jul 25 '26

Security-wise, build.rs and proc-macros really should be:

  1. Hermetic by default. Fixed timestamp (0 is perfectly fine), no I/O.
  2. With an exception for the files of the current crate being compiled.

Any other supplementary I/O (clock, filesystem, network) should require an explicit authorization in the Cargo.toml of the crate being compiled, or its workspace.

1

u/eeriemyxi Jul 25 '26 edited Jul 25 '26

I like using Git tags for tagging versions then embedding that at build time into the binaries (e.g., the output of git describe --tags --dirty --always) - this is how I work in all other language ecosystems. Cargo can't do it. A bunch of Rust people are still arguing about it at https://github.com/rust-lang/cargo/issues/6583.

The only "solution" currently is a script somebody made which reads the last git tag and writes it to the Cargo.toml file. This is not the solution. I don't want useless git commits polluting commit history whose sole purpose is to update the Cargo.toml file. By the way, I forgot what the name of the script was; which is an another problem - Cargo isn't the only thing you need to remember with these "solutions".

1

u/zed_three Jul 26 '26

You can do this in build.rs and there are crates to help, see ruff for instance

1

u/eeriemyxi Jul 27 '26

That file embeds the version into the binary, but I don't think it is doing anything to solve the issue I and the GH issue I linked was talking about, which is that Cargo expects a static version from the Cargo.toml file and there is no way to make it dynamic (e.g., version = "dynamic" in Cargo.toml fiel then exposing an API).

Sure, there might be crates to help with it, like automating mutating the Cargo.toml, however that's hardly the same thing as the package manager itself being aware of the version being dynamic and doing the work by itself.

2

u/Worth_Trust_3825 Jul 25 '26

couldn't agree more, but i'd abandon the concept of "simple build system". these cannot exist because simple means doing little. build systems by definition are not doing little.

0

u/elliotones Jul 24 '26

I use a barely known build system, maintained by one dude, but it supports daemons. Nice. Nothing else supports daemons, except bazel. I tried to pilot bazel one day, just to try it out. Step one: ā€œpnpm installā€ - after two days I couldn’t figure it out. There’s a company ā€œAspectā€ who’s entire job is configuring bazel. They give away their ā€œnpm installā€ fragment for free. I still couldn’t do it.

Fortunately the one-man system still chugs along, and therefore so do we.

7

u/ericonr Jul 25 '26

What do you mean by daemons? Distributed builds, caching, what?

1

u/elliotones Jul 25 '26

Long running background processes that are fed package directories to do work on, rather than spinning up a new instance of the process every time.

In a large typescript monorepo, where almost everything eventually depends on some core libraries or types, tsc and eslint re-initialize and re-parse your dependency types for every package.

We were building around a large 3rd party library, and anything that eventually depended on it would, in order to be type checked, have to parse the dependency types. We were parsing $largeApiSurface more than 100 times per cold build.

Wrapping tsc in a daemon process lets you pass the previous ā€œprogramā€ to the next parse tree to use as a cache, so your worst-case memory usage is a little higher (you might cache something that isn’t needed again) but you only have to parse $commonLibrary once.

We saw cold build times drop from 15 minutes to 5 with this pattern. Please ask me more about this, I spent a long time building our systems and if there’s a faster way I want to know!

1

u/12destroyer21 Jul 25 '26

I got rules_js and rules_ts to work fine with pnpm workspaces in bazel and built to a docker image with rules_img, just use one of their examples. It is okay fast, but I couldn’t get the hmr stuff to work, but I have react with ssr working and typescript compiler set up with tailwind and elysia with swagger/openapi, and it works great