Polly comes in two library flavors: One loadable module to use the LLVM framework -load mechanism, and another one that host applications can link to. These have very different requirements for Polly's own dependencies.
The loadable module assumes that all its LLVM dependencies are already available in the address space of the host application, and is not allowed to bring in its own copy of any LLVM library (including the NVPTX backend in case of Polly-ACC).
The non-module library is intended to be linked to using target_link_libraries. CMake would then resolve all of its dependencies, including NVPTX and ensure that only a single instance of each library will be used.
This is a less invasive alternative to D32392.
I did not manage to make LLVM_LINK_LLVM_DYLIB=ON build work entirely. check-polly works, but trying to install it gives an error
CMake Error at tools/polly/lib/cmake_install.cmake:40 (file): file INSTALL cannot find "/root/build/llvm/release_loadpolly_dylib/tools/polly/lib/CMakeFiles/CMakeRelink.dir/LLVMPolly.so". Call Stack (most recent call first): tools/polly/cmake_install.cmake:46 (include) tools/cmake_install.cmake:37 (include) cmake_install.cmake:62 (include)
According to http://public.kitware.com/pipermail/cmake/2016-July/063992.html this has might not be Polly's fault. It occures with lld as well.