user-provided make variables should override resolved toolchain ones
When we pass environment variables for flags (e.g. ARFLAGS), I noticed that it appends to the resolved toolchain values. This is not always desired, and I expected it to be set to the value I gave it.
Like outside Bazel, if we want to inherit an environment flag, I'd expect the same to be true here. E.g. ARFLAGS="${ARFLAGS:-} foobar". Or the classic export PATH="${PATH}:/some/dir".
I'm posting here to start a discussion of what would be the best way to fix this without breaking the world. Or am I overlooking something obvious?
I guess the main issue with overriding vs taking the values frm the resolved toolchain is that this very likely becomes specific to the specific resolved toolchain value, or you end up with selects at the rule level to choose the correct behaviour.
ARFLAGS seems to be the main one that always causes issues; the macOS toolchain in particular isn't quite correct and often requires setting AR in the env specified. So I think in some regards the correct answer may actually be to fix the underlying issues with using the default toolchain configurations; likely with some custom wrappers around some of the tools to do the right thing (or at least provide some level of configurability to do the right thing).
IIRC the behaviour should be override unless the env variable contains PATH in the name in which case it appends but its possible that there are some cases in the way the bash scripts are structured that this isn't quite what happens.. Open for sane suggestions on how to control this behaviour.