This is an archive of the discontinued LLVM Phabricator instance.

[Polly][Cmake] Optionally use a system isl version.
ClosedPublic

Authored by philip.pfaffe on Feb 16 2017, 6:20 AM.

Details

Summary

This patch adds an option to build against a version of libisl already installed on the system. The installation is autodetected using the pkg-config file shipped with isl.

Usually the detection of the library would go into a FindISL.cmake module that creates an imported target. Here, I do this manually and in the root CMakeLists.txt. The main reason for this is that recent versions of FindPkgConfig (shipped with cmake 3.6 and up) will do this on their own. We should just wait until we can bump the minimum required cmake version to that point, or, if that's not going to happen soon, backport FindPkgConfig from cmake trunk (I didn't do this because I'm not up to speed on licensing).

BTW: The minimum required cmake version of Polly is currently 2.8 if built outside the LLVM tree. We should bump that at least to 3.4.3 to match LLVM.

Diff Detail

Event Timeline

philip.pfaffe created this revision.Feb 16 2017, 6:20 AM

Fix small mistake.

Meinersbur edited edge metadata.Feb 20 2017, 9:49 AM

Thanks for the patch.

I did not understand the argument of not using a FindISL.cmake. You can have a FindISL.cmake and use FindPkgConfig in there? Once we bump to cmake 3.6 we can switch to using IMPORTED_TARGET in there and remove the manual creation of an imported target.

CMakeLists.txt
172

target_include_directories?

185

target_compile_options?

205–208

I'd prefer to declare a variable ISL_INCLUDE_DIRS that contains the required directories and is set by the POLLY_USE_EXTERNAL_ISL-handling mechanism to the directories of choice. It avoids having extra cases for POLLY_USE_EXTERNAL_ISL whenever it is used.

Would using target_include_directories(PollyISL INTERFACE ...) make this unnecessary?

lib/External/CMakeLists.txt
3

Indention

Addressed the comments. I also took the liberty to advance the minimum required cmake version for building out-of-tree. This patch doesn't work with cmake 2.8, because IMPORTED targets aren't supported.

Nevertheless I stumbled onto a minor issue with this approach: if linked into the LLVM tools, the rpaths are lost. CMake builds everything with full rpath by default, but LLVM overwrites this with $ORIGIN/../lib. If Polly is linked statically into a tool, e.g. opt, the isl rpath is gone. Without putting libisl into the LD_LIBRARY_PATH, opt won't find it, or might even pick up the wrong one.

philip.pfaffe marked an inline comment as done.Feb 21 2017, 6:01 AM
philip.pfaffe added inline comments.
CMakeLists.txt
185

This doesn't apply for IMPORTED targets.

philip.pfaffe marked an inline comment as done.Feb 21 2017, 6:33 AM
philip.pfaffe added inline comments.
CMakeLists.txt
205–208

I'm using ISL_INCLUDE_DIRS now.

target_include_directories(PollyISL INTERFACE ...) doesn't easily work here, because you can't have source-tree or build-tree paths on a targets INTERFACE when it's being installed.

Did you forget to add the additional files (cmake/CMakeLists.txt, cmake/FindIsl.cmake)?

I already commit the version bump to cmake 3.4.3.

philip.pfaffe marked an inline comment as done.

I absolutely did. The former was even superfluous.

One suggestion left: I feel that the name POLLY_USE_EXTERNAL_ISL is ambiguous. Could be confused with LLVM_EXTERNAL_*. If it is OFF it uses isl from lib/External/isl. Could we change it to POLLY_BUNDLED_ISL and set it to ON by default? What do you think?

I tried it under Windows as well and it didn't work: no pkg-config available there. pkg_search_module also doesn't allow to configure the isl lib/include dirs manually. However, this is no concern atm as I don't know a reason why I would want an external isl on Windows.

Renamed the POLLY_USE_EXTERNAL_ISL switch to POLLY_BUNDLED_ISL.

Meinersbur accepted this revision.Feb 24 2017, 8:58 AM

Thanks.

I am going to commit it at the next occasion.

This revision is now accepted and ready to land.Feb 24 2017, 8:58 AM
This revision was automatically updated to reflect the committed changes.