4 ms·
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
by jpollock 4y ago
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.
- aaaaaaaaaaab 4y agoWhat if I use the __DATE__ macro?
- jvolkman 4y agoYou'll get "redacted" https://github.com/bazelbuild/bazel/blob/34ce6a23f5a2be58bb59661dd5fc9ab586ea1703/tools/cpp/unix_cc_configure.bzl#L628-L631 https://github.com/bazelbuild/bazel/blob/34ce6a23f5a2be58bb5...
- jpollock 4y agoYes, 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 https://bazel.build/docs/user-manual
- kmarc 4y agoThe 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.
- jpollock 4y agoI 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.
- vbezhenar 4y agoDoes 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?
- joshuamorton 4y agoMtime 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.
- jxramos 4y agoMy 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.
- oftenwrong 4y agoBazel 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.