bazel-contrib / bazel-contrib/rules_foreign_cc
make binary is not deterministic
- Dominant language
- Starlark
- Stars
- 737
- Forks
- 270
- PR merge metrics
- No merged PRs in 30d
Description
I've been tracking a bunch of non-determinism issues we have in our build and a pretty fundamental one seems to be that the make binary produced by `rules_foreign_cc` is not deterministic, yielding to downstream invalidations of anything using `rules_foreign_cc`.
Minimal repro:
```
$ bazel clean
$ bazel build --config=no-remote @rules_foreign_cc//toolchains:make_tool && cp bazel-bin/external/rules_foreign_cc/toolchains/make/bin/make make.1
$ bazel clean
$ bazel build --config=no-remote @rules_foreign_cc//toolchains:make_tool && cp bazel-bin/external/rules_foreign_cc/toolchains/make/bin/make make.2
$ md5sum make.1 make.2
```
After a lot of pain diagnosing other proximate issues that weren't the root cause, I was able to fix this by patching `foreign_cc/built_tools/make_build.bzl` to use `make install-strip` instead of `make install`. Assuming `ar` is correctly configured in the toolchain to use `-D`, then this seems to be sufficient.
I also wonder if the default targets passed to `make` and `configure_make` should default to `install-strip` (maybe depending on C compiler settings)? This seems hard in the general case because there is no guarantee that the built packages follow the Automake conventions... but I wonder if something could be done to make this issue more prominent, in the docs or elsewhere, as otherwise it seems too easy to trigger this footgun.
Contributor guide
Research direction
Start with foreign_cc/built_tools/make_build.bzl and reproduce the two builds from the issue using bazel clean, the no-remote configuration, and md5sum. Check whether the produced make binaries match across builds; done means the reported non-determinism is removed, while the broader defaults and documentation question is resolved or explicitly scoped.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100