[cfe-dev] Configuration files

Joerg Sonnenberger via cfe-dev cfe-dev at lists.llvm.org
Wed Sep 28 02:13:00 PDT 2016

On Wed, Sep 28, 2016 at 01:39:59PM +0700, Serge Pavlov via cfe-dev wrote:
> This feature addresses at least two different use cases:
> 1. Config file as a way to override compiler defaults.
> Compiler already has some default settings and it is hardly possible to
> find the settings that suit everybody. For instance, the warning
> -Wundefined-var-template
> is helpful for some users but annoys others. With config file a user could
> put new defaults there and thus customize the compiler. No changes to build
> script is required. Note, this scenario requires just default config files.

This is *exactly* why I am *strongly* against this. Yes, users do that.
Afterwards, they start to fill random bug reports against projects that
break, because the invocation includes -Werror. This is even worse than
setting a global CFLAGS or CXXFLAGS variable since the expansion of
those are at least generally visible. Hidden user-modifable sources of
flags are a support nightware.

> Setting config file via environment variable is a variant of this scenario,
> it allows modification of compiler options without touching build scripts.

See above. Same deal.

> Intel compiler implements both default config and environment variable as a
> way to modify compiler option and practice proved their convenience.

I dare to say that ICC tends to be used in a much more limited
environment. If you want to allow magic environmental variables in your
build script that are invisible for the casual observer, it is not
difficult to add. Well written build systems already support that

> 2. Config file as an "option macro".
> Some users, especially those using cross-compilation, want to have
> possibility to define an "option" that when applied specifies a set of
> other options. An example: switching from one target processor to another
> which requires change of sysroot, libraries, triple etc. By organizing
> these options into config files, work with several build variants becomes
> more convenient.
> This scenario requires to specify particular config file, either by option
> --config or by encoding it in compiler executable like clang-conf.
> Clang based ELLCC Compiler uses these kind of config files and they are
> proved to be convenient (
> http://lists.llvm.org/pipermail/cfe-dev/2016-September/050783.html).

There was a reasonable proposal when this came up in the past. If you
have an invocation like ${target}-clang, look for a ${target}.cfg option
file and parse that. The lookup should be limited to something derived
from the static configuration and -B options.


PS: It is a PITA to reasonable respond to mails that aggregate feedback
to a complete thread.

More information about the cfe-dev mailing list