[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs (WIP)

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 27 00:07:09 PDT 2022


sepavloff added a comment.

In D134337#3815705 <https://reviews.llvm.org/D134337#3815705>, @MaskRay wrote:

> In D134337#3815412 <https://reviews.llvm.org/D134337#3815412>, @mgorny wrote:
>
>> In D134337#3815339 <https://reviews.llvm.org/D134337#3815339>, @sepavloff wrote:
>>
>>> In D134337#3805368 <https://reviews.llvm.org/D134337#3805368>, @mgorny wrote:
>>>
>>>> For target, it will try:
>>>>
>>>> 1. `i386.cfg` (effective triple)
>>>> 2. `i386-pc-linux-gnu.cfg` ("fixed" prefix)
>>>> 3. `x86_64-pc-linux-gnu.cfg` (orig. prefix)
>>>
>>> Does it mean that `i386.cfg` would be tried before `i386-pc-linux-gnu.cfg`? It looks more natural to try specific variant first then generic. File `x86_64.cfg` is not used in this algorithm, what is the reason for this?
>>
>> Yes but this is only because the example explicitly passes `-target i386`, i.e. incompletely triple. If you passed `-target i386-pc-linux-gnu`, then it would try that one instead. Perhaps I should try and see what triple normalization does here.
>
> Trying just `i386.cfg` for `x86_64-pc-linux-gnu-clang --target=i386` makes sense to me. Trying `x86_64*.cfg` seems inappropriate.
> I do not recommend `i386-pc-linux-gnu.cfg` since `--target=` is as if completely ignoring the executable prefix.
>
> If `x86_64-pc-linux-gnu-clang --target=i386-pc-linux-gnu` is specified, trying `i386-pc-linux-gnu-clang.cfg` makes sense. I do not know whether `i386-clang.cfg` should be tried as well.

It make sense but the algorithm looks overcomplicated. The current implementation is already too complex and documenting the new algorithm is a challenge.

What about making minimal changes to the current algorithm so that the task of @mgorny can be done, without reasoning about possible profit for someone else? Our customers don't use target overloading and prefixes longer than target, so any change that preserve existing functionality is OK.

A part of this algorithm that loads driver mode configuration is worth implementing:

In D134337#3805368 <https://reviews.llvm.org/D134337#3805368>, @mgorny wrote:

> For driver, it will try:
>
> 1. `clang++.cfg` (effective mode)
> 2. `clang.cfg` (suffix)

It must not break compatibility with existing implementation and allows further extension in future. For more complex use cases driver configuration may implement mode complex syntax as proposed in https://discourse.llvm.org/t/rfc-adding-a-default-file-location-to-config-file-support/63606/41.

@mgorny what modifications to target mode file search are necessary for your task?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134337/new/

https://reviews.llvm.org/D134337



More information about the cfe-commits mailing list