This is an archive of the discontinued LLVM Phabricator instance.

[lit] Update clang and lld to use the new shared LLVMConfig stuff
Needs ReviewPublic

Authored by zturner on Sep 13 2017, 11:52 AM.

Details

Summary

This is probably the last work I'm going to do here for a while. I still see some room for improvement, but I think after this patch:

a) refactor begins to have diminishing returns
b) There's a sufficient amount of sharing and re-use to validate the design
c) There's enough specific examples of how to use this that other projects (e.g. compiler-rt, etc) can use those as a model of how to simplify their own configs.

In other words, I'm not brave enough to touch compiler-rt's config files :)

There's some minor changes in the config api that increase flexibility in how you override environment variables and spawn an external llvm-config, but otherwise this is mostly just deleting code.

Diff Detail

Event Timeline

zturner created this revision.Sep 13 2017, 11:52 AM
rnk added inline comments.Sep 13 2017, 12:39 PM
llvm/utils/lit/lit/llvm/config.py
92

Rather than having an optional parameter that makes this append, maybe have a new method that calls this one after doing the path appending. How about append_environment_path(var, value) or something?

dlj added inline comments.Sep 13 2017, 12:40 PM
clang/test/lit.cfg
23

Minor nit: it seems reasonable enough to name this parameter:

ShTest(execute_external=(not llvm_config.use_lit_shell))

(I don't think that's a problem for ShTest.init, and has the benefit of failing if the parameter name changes. Imagine if someone added another default-valued bool argument to ShTest.__init__...)

llvm/utils/lit/lit/llvm/config.py
93

Looking at the callers of this... should the path-append logic be a separate function?

For example:

llvm_config.with_environment('PATH', [config.llvm_tools_dir, config.clang_tools_dir], append_path=True)

versus maybe this:

llvm_config.append_env_pathvar('PATH', [config.llvm_tools_dir, config.clang_tools_dir])

128–129

You could also say:

for name in variables:
    self.config.environment.pop(name, None)
132

I think the expected format of the 'features' arg is complex enough that you should add a docstring that explains it...

134

I think you could probably just use features.keys() for this, no?

147

You might want to use splitlines() for Windows compatibility.

MatzeB resigned from this revision.Jan 11 2018, 10:10 AM