<div dir="ltr">I really don't see what the purpose of this feature is, if it's only going to work effectively identically to an "@args-file" option.<div><br></div><div>If that's all you want, it doesn't even need to be in the clang driver, a 5 line shell script that looks at $0 to choose a config file to read can work just as well.</div><div><br></div><div>But I don't think that's really what people want -- I believe that any workable config-file scheme *must* interact with the various target specification command-line arguments, and allow for setting options dependent upon the actually-selected target.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 20, 2016 at 3:13 AM, Serge Pavlov via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Thanks to all for feedback!</div><div><br></div><div>I tried to summarize the feedback in the form of user-visible description (possibly a part of user documentation) and random set of development specific notes.</div><div><br></div><div>------ User documentation ------</div><div><br></div><div>Using clang as a part of toolchain, especially in the case of cross-compilation, require setting up large amount of parameters - location of headers and libraries, set of enabled warnings, triplet names etc. Changing from debug to release build, or from host processor to accelerator or any other change of build configuration requires substantial changes of these parameters. To help maintaining option sets for various build variants, sets of options may be combined into configurations and stored in *configuration files*. Selection of particular configuration file activates all options it represents.</div><div><br></div><div>Configuration file may be selected in several ways:</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>- Using command line option --config,</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">       </span>- By setting up environmental variable CLANGCFG,</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">    </span>- As default configuration.</div><div>Only one way may be used. If option ''--config" is specified, CLANGCFG is not checked and the default configuration is not be applied even if the requested configuration is not found. Similarly, if variable CLANGCFG exists, default configuration is never applied.</div><div><br></div><div>Command line option --config expects argument either full path to configuration file, or a name of configuration, for instance:</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">       </span>--config /home/user/cfgs/testing.cfg</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>--config debug</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">      </span>--config debug.cfg</div><div>If full path is specified, options are read from that file. If configuration is specified by name with optional suffix ".cfg", corresponding configuration file is searched in the directories in the following order:</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>- ~/.llvm</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>- /etc/llvm</div><div><br></div><div>If the option --config is absent, and environment variable CLANGCFG is set, content of CLANGCFG is used as full path to configuration file. If CLANGCFG is empty, config file is not used, no diagnostic produced.</div><div><br></div><div>If neither --config nor CLANGCFG are specified, default config file is searched in the following order:</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>- ~/.llvm/clang.cfg</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>- /etc/llvm/clang.cfg</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">       </span>- clang.cfg in the directory where clang executable resides.</div><div><br></div><div>Configuration file is the sequence of compiler options specified in one or several lines. Lines started with '#' possibly prepended with space characters are comments, they are ignored. Lines started with '#" in the first column immediately followed by ':' are reserved for directives. The file may reference other files using usual syntax for response files: @included_file. Example of configuration file:</div><div><br></div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">        </span># Frontend options</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">  </span>-std=c++14 -fcxx-exceptions</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap"> </span># Directories</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">       </span>@include-dirs.cfg</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>@library-dirs</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">       </span></div><div>Name of the active configuration file and options it provided can be obtained by call of clang with options '-v' or '-###'.</div><div><br></div><div>------ End of user documentation ------</div><div><br></div><div>Notes:</div><div><br></div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">    </span>1. What should be the name of default config file, 'default.cfg' or 'clang.cfg'? If some tool other than clang will use the same mechanism, name 'clang.cfg' looks more appropriate.</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>2. Should compiler emit a warning (or even an error) if the specified configuration file was not found? Obviously absence of default config file should be silently ignored, as well as empty CLANGCFG variable. But what if configuration specified by --config is not found? This looks like a severe error, as user expectation are broken.</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">      </span>3. Default config file may be searched for in  the directory where clang executable resides. Should configuration specified by --config be searched in this directory as well? I would say no, because a user who need tuning configurations may prepare them in home directory or use those provided by installation in system directories. Ability to place default config into binary directory is convenient for compiler developer or CI tools, they may uses several variants of compiler simultaneously.</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">    </span>4. Format of proposed config file is in fact gnu response file. YAML format mentioned by Richard looks nice but it requires development of proper parser. I would propose at first implement the simple format. In future other format can be supported, we can distinguish formats by putting a directive like '#:format=yaml' or even automatically.</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">      </span>5. Some comments may be reserved for future use. Format directive mentioned above is an example. The sequence '#:' proposed as marker is absolutely arbitrary, any other prefix may be used. Now compiler may warn if it sees such comment. Probably we do not need to bother about the future extensions now.</div><div><span class="m_-6835046580999436729gmail-Apple-tab-span" style="white-space:pre-wrap">      </span>6. Using response files in the form @file can imitate include directive. If a user do not want to copy-and-past pieces of config files, he may structure them using this feature.</div><div><br></div><div class="gmail_extra"><br clear="all"><div><div class="m_-6835046580999436729gmail_signature" data-smartmail="gmail_signature">Thanks,<br>--Serge<br></div></div>
<br></div></div>
<br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>