News for hackers. Stuff that matters.
Re:When to use Bazel? by jpollock on Tuesday September 13, 2022 @04:45PM (#32829976)
Bazel is more strict about what constitutes a dependency change. It doesn't use mtime on the file, it relies on the checksum. It also considers the command line flags to be part of the cache key.

So, spurious changes (touching a file) will result in a cache hit, while hidden changes (changing an environment flag used by Make) are caught.

This is particularly important if verifiable builds are needed for SoX compliance.

Re:When to use Bazel? by aaaaaaaaaaab on Tuesday September 13, 2022 @04:51PM (#32830028)
What if I use the __DATE__ macro?
Re:When to use Bazel? by jvolkman on Tuesday September 13, 2022 @05:13PM (#32830245)
Re:When to use Bazel? by jpollock on Tuesday September 13, 2022 @05:14PM (#32830257)
Yes, you can go out of your way to make your builds non-deterministic. That should break in Make as well.

I don't know enough about bazel to answer your question definitively, but "stamping" is what you want to search for.

https://bazel.build/docs/user-manual

Re:When to use Bazel? by kmarc on Tuesday September 13, 2022 @05:17PM (#32830288)
The better question is, what if you change a comment?

It checksums the preprocessed files, so neither `__DATE__`, no comment changes should affect your build times.

Re:When to use Bazel? by jpollock on Tuesday September 13, 2022 @05:46PM (#32830556)
I think __DATE__ without redaction pushes the dependency change 1 level down, to the .o file.

The .a/.so/.exe would no longer match the inputs (the .o files), causing a re-link.

Re:When to use Bazel? by vbezhenar on Tuesday September 13, 2022 @06:26PM (#32830966)
Does it re-read every single source file to find out which were changed? Sounds like a terrible approach. Or it uses mtime first and checksum after that?
Re:When to use Bazel? by joshuamorton on Tuesday September 13, 2022 @07:06PM (#32831286)
Mtime first is unreliable on modern (fast) machines, you can edit a file twice in a single second. I think bazel has a daemon watch for file changes, but I'm not certain of that.
Re:When to use Bazel? by simoncion on Wednesday September 14, 2022 @12:37AM (#32833372)
ext4, btrfs, XFS all use nanosecond time resolution.
Re:When to use Bazel? by jpollock on Wednesday September 14, 2022 @12:39PM (#32839666)
Think remote file system where a different node is providing the mtime, so it can have substantial diffs between nodes.
Re:When to use Bazel? by oftenwrong on Wednesday September 14, 2022 @05:20AM (#32834868)
Bazel has a stateful server component that caches information about the build graph and source files in memory. As you said, this allows it to check mtimes first to avoid re-computing hashes for source files.

Bazel can also read source file hashes from the filesystem if the filesystem supports it.

Re:When to use Bazel? by jxramos on Wednesday September 14, 2022 @01:41AM (#32833677)
My understanding is that somehow the bazel server tracks all that and keeps a hot process for monitoring the source files somehow to make the file io more bearable.