[PATCH] D24933: Enable configuration files in clang

Stephen Hines via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 18 18:21:16 PST 2016


srhines added a comment.

Thanks to Hans for notifying me about this. Cross-compilation flags are a big challenge in Android, but I have similar concerns about looking for magic files/dirs. Richard's suggestion about improving @file is really interesting, and would satisfy a large part of our needs in Android. Can you comment on whether you think that would work for your cases as well?



================
Comment at: docs/UsersManual.rst:655-656
+
+Command line option `--config` can be used to specify configuration file in
+a clang invocation. For instance:
+
----------------
rsmith wrote:
> Rather than inventing a new mechanism, could we extend our existing `@file` facility to support comments and nested inclusion of further `@file`s?
This is a very interesting idea, and seems like something that would be very interesting for large systems that do a lot of cross-compilation. For instance, in Android, I would love to have a set of generic flags to add to all of our cross-compiles, and then a set of per-ABI flags for each of our major targets. If I could nest @file directives, that would get me most of this with minimal/no duplication of flags.


================
Comment at: docs/UsersManual.rst:667
+extension `cfg` if it is not specified yet, and the obtained file name is searched
+for in the directories: `~/.llvm` and the directory where clang executable resides.
+The first found file is used. It is an error if the required file cannot be found.
----------------
rsmith wrote:
> hans wrote:
> > The "add .cfg extension" magic seems a little awkward. It seems this is mixing the possibility of taking a filename and taking some other name.
> > 
> > For `clang --config myfile.cfg`, should it also search the current working directory?
> > 
> > I'm not keen on it searching in `~/.llvm`.
> I'm also not keen on searching `~/.llvm`. Whoever makes the `blah-clang` symlink should get to control what the default configuration for `blah-clang` is, I think. But then this seems to immediately lead to the conclusion that we don't need this implicit-config-file feature at all, since you can replace a `blah-clang` symlink with a shell script containing `exec clang @blah.cfg "@$"` -- and it's better to handle it that way, since you get more control over where the config file lives.
Android is essentially taking the shell script wrapper approach today (although we are using python, and we don't do a lot with it just yet).


https://reviews.llvm.org/D24933





More information about the cfe-commits mailing list