Re:When to use Bazel?
by aaaaaaaaaaab on Tuesday September 13, 2022 @04:51PM
(#32830028)
What if I use the __DATE__ macro?
You'll get "redacted"
https://github.com/bazelbuild/bazel/blob/34ce6a23f5a2be58bb5...
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.
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.
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.
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.
ext4, btrfs, XFS all use nanosecond time resolution.
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.
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.