[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
Sun Sep 25 09:09:39 PDT 2022


sepavloff added a comment.

I would propose to slightly modify the config file search algorithm.

For the tool named as `x86_64-pc-linux-gnu-clang`, the existing algorithm would search for the files:

- `i386-clang.cfg`
- `i386.cfg`
- `x86_64-clang.cfg`
- `x86_64.cfg`

We could modify this algorithm to obtain more flexible one and still preserve backward compatibility as much as possible. Let's use  the invocation `x86_64-pc-linux-gnu-clang --driver-mode=g++ -target i386` as example and see what files the tool would search for in the modified algorithm.

First clang tries to find `x86_64-pc-linux-gnu-clang.cfg`. Just tool name with added suffix `cfg`. No target override, no attempt to split tool name into components. It provides possibility to have a separate configuration for any tool. The existing mechanism does not search for such file, so compatibility cannot be broken. This variant makes it possible to use configuration file even if tool name is arbitrary and does not follow usual pattern.

If `x86_64-pc-linux-gnu-clang.cfg` is found, it is loaded as configuration file and that's all. Otherwise the middle components are dropped and only target prefix and driver mode suffix are used for the search. It is similar to the search made by existing implementation, the following files that are looked for :

- `i386-clang.cfg`
- `i386.cfg`
- `x86_64-clang.cfg`
- `x86_64.cfg`

If the file found has form `target.cfg` or none of the files was found, clang tries to load driver-mode configuration file. The files are the same as in your algorithm:

- `clang++.cfg`
- `clang.cfg`

The driver-mode configuration is loaded prior to the target config, - as it may contain default settings that target config may override. In the current implementation such files are not, risk of breaking compatibility is minimal.

What do you think about this variant? Does it fit your use case?


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

https://reviews.llvm.org/D134337



More information about the cfe-commits mailing list