This adds support for the lld-only --thinlto-cache-policy option, as well as implementations for ld64's -cache_path_lto, -prune_interval_lto, -prune_after_lto, and -max_relative_cache_size_lto.
Because llvm::CachePruningPolicy has reasonable default values, it's infeasible to give --thinlto-cache-policy precedence over the individual ld64 cache pruning options without replicating the parsing code. Currently, we ignore the individual options when the composite option is provided, but we can also give the individual options precedence if that seems better.
Test is adapted from lld/test/ELF/lto/cache.ll
I'd put this in the loop above: If you say -prune_interval 10 --thinlto-cache-policy=20s -prune_interval 30 I think it's least surprising if you end up with a prune interval of 30s.
We usually follow a "last setting on commandline wins" policy: For example, -Wno-return-type disables the warning for missing return types, -Wno-return-type -Wall enables it because -Wall is later and overrides it, -Wno-return-type -Wall -Wno-return-type disables it. That's a somewhat academic discussion since in practice nobody will pass both kinds of flags here, but I think it's still better to process them in order.
Also, as-is, this ignores all but the last --thin-lto-cache-policy= flag, and processing them in the loop together with the others fixes that too.