Page MenuHomePhabricator

[lldb] [cmake] Use install directories for LLVM_* variables

Authored by mgorny on Feb 9 2019, 4:52 AM.



Restore the previous behavior of using install directories for
from llvm-config to CMake has changed the values of those values to use
LLVM_BUILD_* which is plain wrong and breaks stand-alone builds.
Instead, use the CMake counterparts of the values returned
by llvm-config.

Event Timeline

Indeed, these variables do not exist when running against a LLVM/Clang install-tree and this should be fixed. Did you give this a try running against a LLVM/Clang build-tree? Dumping the values here locally, gives me:

LLVM_BUILD_MAIN_INCLUDE_DIR /path/to/llvm/include
LLVM_BUILD_LIBRARY_DIR      /path/to/llvm-build/./lib
LLVM_BUILD_BINARY_DIR       /path/to/llvm-build

LLVM_INCLUDE_DIR            /path/to/llvm/include;/path/to/llvm-build/include
LLVM_LIBRARY_DIR            /path/to/llvm-build/./lib
LLVM_BINARY_DIR             /path/to/llvm-build

Hope the two paths that the build-tree LLVMConfig sets for LLVM_INCLUDE_DIR is not causing issues.

Indeed it is a problem. However, it seems to be a bug that LLVM_INCLUDE_DIR contains two directories. Apparently in regular builds it contains the directory with built includes only, with LLVM_MAIN_INCLUDE_DIR being the other directory. In other words, it's a mess ;-/.

mgorny updated this revision to Diff 186427.Feb 12 2019, 2:23 AM

Updated to use exported LLVM_MAIN_INCLUDE_DIR, as introduced by D58109. This works both for build-tree and install-tree, and avoids having to introduce any conditionals.

Indeed it is a problem. However, it seems to be a bug that LLVM_INCLUDE_DIR contains two directories.

Yes, especially since we also have LLVM_INCLUDE_DIRS. But that's not the end.. in llvm/cmake/modules/CMakeLists.txt we set:


The template stores it as:


# These variables are duplicated, but they must match the LLVM variables of the
# same name. The variables ending in "S" could some day become lists, and are
# preserved for convention and compatibility.

The install step fixes that and generates:



  • LLVM itself and clients of the install-tree see LLVM_INCLUDE_DIR=/path/to/llvm-build/include
  • Clients of the build-tree see LLVM_INCLUDE_DIR=/path/to/llvm/include;/path/to/llvm-build/include

This should really be fixed. Looks like the confusion started with and manifested with

In other words, it's a mess ;-/.

Yes, definitely

I just caught up to this thread and wow, yeah things are far more broken than I realized. Apologies for opening this can of worms.

That being said, thanks for taking the time to look at it and clean it up.

xiaobai accepted this revision.Feb 12 2019, 3:47 PM

After looking at the dependent patch, this looks good to me.

This revision is now accepted and ready to land.Feb 12 2019, 3:47 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 13 2019, 12:34 AM