Page MenuHomePhabricator

CMake: Deprecate using llvm-config to detect llvm installation

Authored by tstellar on Sep 5 2018, 8:13 PM.



clang currently uses llvm-config to determine the installation paths
for llvm's headers and binaries. clang is also using LLVM's cmake
files to determine other information about the LLVM build, like
LLVM_LIBDIR_SUFFIX, LLVM_VERSION_*, etc. Since the installation
paths are also available via the cmake files, we can simplify the code
by only relying on information from cmake about the LLVM install and
dropping the use of llvm-config altogether.

In addition to simplifying the code, the cmake files have more
accurate information about the llvm installation paths. llvm-config
assumes that the lib, bin, and cmake directories are always located
in the same place relative to the path of the llvm-config executable.
This can be wrong if a user decides to install headers, binaries
or libraries to a non-standard location: e.g. static libraries
installed to /usr/lib/llvm6.0/

This patch takes the first step towards dropping llvm-config by
removing the automatic detection of llvm-config (users can still
manually supply a path to llvm-config by passing
-DLLVM_CONFIG=/usr/bin/llvm-config to cmake) and adding a
deprecation warning when users try to use this option.

Diff Detail

rC Clang

Event Timeline

tstellar created this revision.Sep 5 2018, 8:13 PM

Is LLVM_CONFIG dropped from cache here? I suspect the warning might fire for everyone who has LLVM configured.

Is LLVM_CONFIG dropped from cache here? I suspect the warning might fire for everyone who has LLVM configured.

Yes, it is dropped from the cache, is it a problem to having the warning fire for people who have already configured LLVM?

mgorny added a comment.Sep 6 2018, 9:50 AM

I don't have a strong opinion here.

steveire accepted this revision.Sep 6 2018, 11:43 AM
steveire added a subscriber: steveire.

Brilliant, I've wanted to do this for years, and I still have many improvements to the LLVM/Clang cmake files on my todo list. Good to know others are similarly motivated.


message(DEPRECATION) is designed for deprecation messages. It announces itself as a "CMake Deprecation Warning at CMakeLists.txt:6 (message):".

The user can silence the warning with -Wno-deprecated or make it an error with Wdeprecated since old versions of CMake:

This revision is now accepted and ready to land.Sep 6 2018, 11:43 AM

Is there anything holding this up?

tstellar updated this revision to Diff 167413.Sep 27 2018, 4:18 PM

Use cmake's DEPRECATION message.

Is there anything holding this up?

No hold up, I just wanted to address the review comment. I'll commit on Monday if there are no other comments.

This revision was automatically updated to reflect the committed changes.