[cfe-dev] Configuration files

Renato Golin via cfe-dev cfe-dev at lists.llvm.org
Mon Sep 19 03:05:59 PDT 2016


On 19 September 2016 at 09:06, Serge Pavlov via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> Content of configuration file
> is treated as a part of command line of each tool invocation preceding any
> arguments specified in command line.

This has been discussed before, but it died out a bit. I am personally
in favour of this proposal, but I think this could be expanded just a
bit and do much more.

One big problem we have is that GNU cross-compilation toolchains are
created in different ways, with different options, paths, libraries,
support by different distributions, so it's practically impossible for
the Clang driver to keep up with all of them. The end result is that
users have to fiddle with --sysroot, -L, -I, -l, triple names, etc.
This gets even more complicated when adding compiler-rt, libc++ and
especially libunwind. Also bad is the choices between GNU and LLVM
tools for native and cross compilation, which drives the number of
possibilities times the number of distribution-specific configurations
through the roof.

So, I'd like to extend your proposal...

You said:
 * If no config file is found, do nothing
 * If the default config is found, pre-pend (not append, because of
last-seen effect) all the options to the user's command line

I'd add:
 * If there's a system default (/etc/llvm/default.cfg), silently use that
 * If there's a user default (~/.llvm/default.cfg), silently *replace*
the system config
 * If Clang uses the option "--config foo.cfg", *replace* any other,
with reverse search patch (first local dir, then ~/.llvm, then
/etc/llvm)
 * Allow the user to omit the ".cfg" extension, or not even create it
in the first place (I prefer it that way, see below)
 * Clang -v and -### to show which configuration it's using (full path)

This would allow one to create a number of configurations to help
users get what they want, for example:
 * Use Compiler-RT and libc++ installed on the system by choosing
"--config rt-libcxx", hiding all distro-specific choices (-L, -I) form
the user
 * Cross-compile to ARM based on the distro's multi-arch config with
"--config cross-armv7l-linux-gnueabihf"
 * Only enable "-Werror" on a final build, not development ones by
making the "--config werror" optional in CMake/Make files (ex. based
on -DDEBUG flags)

It would also help developers reproduce bug reports, if the user
provides their config file (when you don't have a crash script).

Finally, it would give us time to refactor the Clang driver for
cross-compilation by hiding the complexity behind the config file
while it's too ugly and also allow it to move without upsetting too
many users.

cheers,
--renato



More information about the cfe-dev mailing list