This is an archive of the discontinued LLVM Phabricator instance.

[CMAKE] Provide default location for llvm-lit for out-of-tree users.
ClosedPublic

Authored by stephenneuendorffer on Mar 30 2020, 5:52 PM.

Details

Summary

Several external build users contain some heuristics for finding llvm-lit.
There are several cases we need to worry about:

  • External builds against a build tree (with LLVM_BUILD_UTILS)
  • External builds against an install tree (with LLMV_BUILD_UTIL and LLVM_INSTALL_UTILS)
  • External builds against some location which doesn't have an llvm-lit, but llvm-lit is available through some other means, such as an available source tree, or a packager provided llvm-lit.

For the third case, LLVM_EXTERNAL_LIT suffices, but in other cases
there's no standard way to find llvm-lit. It seems like each user
cooks their own heuristics:

  • clang tries to look in the LLVM source tree, and failing that falls back to looking for a packaged llvm-lit.
  • libcxx tries to look in the LLVM source tree, which might come from llvm-config or be explicitly specified.

This patch is a first stop to solving this by providing a default location
for llvm-lit using LLVM_DEFAULT_EXTERNAL_LIT. The expectation is that
future patches can clean up users like clang and libcxx to rely
on this mechanism for out-of-tree builds.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2020, 5:52 PM

How will LLVM_DEFAULT_EXTERNAL_LIT be used? Will other sub-projects be udpated to use this instead of the existing heuristics?

llvm/cmake/modules/CMakeLists.txt
112–116

Why do we need to set this again?

stephenneuendorffer marked an inline comment as done.Mar 31 2020, 2:07 PM

How will LLVM_DEFAULT_EXTERNAL_LIT be used? Will other sub-projects be udpated to use this instead of the existing heuristics?

LLVM_DEFAULT_EXTERNAL_LIT is an existing mechanism that can be used to point to llvm-lit. I'd like to see everything use the same mechanism.
This is either going to require a) verifying that this works in other environments (windows?) and updating users to use it, removing usage of llvm-config
in the process, or b) taking one of the existing paths, removing usage of llvm-config and extracting it into something in llvm/cmake/modules
to eliminate the copy-pasta and then rebuilding around that. Either of these paths is going to require some input and investment from people who
understand more about the global picture here: I don't have the bandwidth or understanding of the various use cases to take this all on by myself.

llvm/cmake/modules/CMakeLists.txt
112–116

There are basically 2 copies of the configuration information generated here. One is describing the build area (allowing one to do an external build with LLVM_DIR pointing at build area), and one which describes an install area. These are subtly different. Here the difference is that if llvm-lit is not installed (LLVM_INSTALL_UTILS=off) then it won't exist in the build area and we don't set a default. Users would still be able to specify LLVM_EXTERNAL_LIT to point to any lit that they care to.

stephenneuendorffer edited the summary of this revision. (Show Details)
stephenneuendorffer marked an inline comment as done.

Any objections to this going in as is?

tstellar accepted this revision.Apr 22 2020, 11:28 AM
This revision is now accepted and ready to land.Apr 22 2020, 11:28 AM
This revision was automatically updated to reflect the committed changes.