<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 1 March 2017 at 02:50, Serge Pavlov via Phabricator <span dir="ltr"><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">sepavloff added a comment.<br>
<br>
Glad to know that someone is interested in this feature!<br>
Below is actual proposal.<br>
<br>
**Adding named configuration files to clang driver**<br>
<br>
A configuration file is a collection of driver options, which are inserted into command line before other options specified in the clang invocation. It groups related options together and allows specifying them in simpler, more flexible and less error prone way than just listing the options somewhere in build scripts. Configuration file may be thought as a "macro" that names an option set and is expanded when the driver is called. This feature must be helpful when a user need to specify many options, cross compilation is likely to be such case.<br>
<br>
Configuration file can be specified by either of two methods:<br>
<br>
- by command line option `--config <config_file>`, or<br>
- by using special executable file names, such as `armv7l-clang`.<br>
<br>
If the option `--config` is used, its argument is treated as a path to configuration file if it contains a directory separator, otherwise the file is searched for in the set of directories described below. If option `--config` is absent and clang executable has name in the form `armv7l-clang`, driver will search for file `armv7l.cfg` in the same set of directories. Similar encoding is already used by clang to specify target.<br>
<br>
The set of directories where configuration files are searched for consists of at most three directories, checked in this order:<br>
<br>
- user directory (like `~/.llvm`),<br>
- system directory (like `/etc/llvm`),<br>
- the directory where clang executable resides.<br>
<br>
User and system directories are optional, they are reserved for distribution or SDK suppliers. By default they are absent, corresponding directories can be specified by cmake arguments `CLANG_CONFIG_FILE_SYSTEM_DIR` and `CLANG_CONFIG_FILE_USER_DIR`. The first found file is used.<br>
<br>
Format of configuration file is similar to file used in the construct `@file`, it is a set of options. Configuration file have advantage over this construct:<br>
<br>
- it is searched for in well-known places rather than in current directory,<br></blockquote><div><br></div><div>This (and suppressing unused-argument warnings) might well be sufficient to justify a different command-line syntax rather than @file...</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- it may contain comments, long options may be split between lines using trailing backslashes,<br>
- other files may be included by `@file` and they will be resolved relative to the including file,<br></blockquote><div><br></div><div>... but I think we should just add these extensions to our @file handling, and then use the exact same syntax and code to handle config files and @file files. That is, the difference between @ and --config would be that the latter looks in a different directory and suppresses "unused argument" warnings, but they would otherwise be identical.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- the file may be encoded in executable name,<br>
- unused options from configuration file do not produce warnings.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D24933" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D24933</a><br>
<br>
<br>
<br>
</blockquote></div><br></div></div>