Change the default config file loading logic to be more flexible
and more readable at the same time. The new algorithm focuses on four
locations, in order:
- <triple>-<mode>.cfg using real driver mode
- <triple>-<mode>.cfg using executable suffix
- <triple>.cfg + <mode>.cfg using real driver mode
- <triple>.cfg + <mode>.cfg using executable suffix
This is meant to preserve reasonable level of compatibility with
the existing use, while introducing more flexibility and making the code
simpler. Notably:
- In this layout, the actual target triple is normally respected, and e.g. in -m32 build the x86_64-* configs will never be used.
- Both real driver mode (preferable) and executable suffix are supported. This permits correctly handling calls with explicit --driver-mode= while at the same time preserving compatibility with the existing code.
- The first two locations provide users with the ability to override configuration per specific target+mode combinaton, while the next two make it possible to independently specify per-target and per-mode configuration.
- All config file locations are applicable independently of whether clang is started via a prefixed executable, or bare clang.
- If the target is not explicitly specified and the executable prefix does not name a valid triple, it is used instead of the actual target triple for backwards compatibility.
This is particularly meant to address Gentoo's use case for
configuration files: to configure the default runtimes (i.e. -rtlib=,
-stdlib=) and --gcc-install-dir= for all the relevant drivers,
as well as to make it more convenient for users to override -W flags
to test compatibility with future versions of Clang easier.
I would say this paragraph is a combination of two provided below. IMHO.