[PATCH] D24442: cmake: Specify library dependences even without BUILD_SHARED_LIBS

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 12 07:49:12 PDT 2016


Meinersbur added a comment.

In which configuration does the link error occur? I could not reproduce it.

Wouldn't it be a lot easier to `target_link_libraries(opt LLVMTarget)` if LINK_POLLY_INTO_TOOLS?


================
Comment at: lib/CMakeLists.txt:69
@@ -68,2 +68,3 @@
 
-if (BUILD_SHARED_LIBS)
+if (LLVM_LINK_LLVM_DYLIB)
+  target_link_libraries(Polly
----------------
AFAIU this gives priority of linking against libLLVM.so over linking agains the individual LLVM components. Since there is a separate option `LLVM_BUILD_LLVM_DYLIB`, this looks like the right thing to do, but could land in a separate commit.

(Although, I think the combination `BUILD_SHARED_LIBS` and `LLVM_LINK_LLVM_DYLIB` is not something that is supposed to work. cmake stop with the error
```
CMake Error at tools/llvm-shlib/CMakeLists.txt:41 (list):
  list sub-command REMOVE_DUPLICATES requires list to be present.
```
)

================
Comment at: lib/CMakeLists.txt:76
@@ -70,1 +75,3 @@
+  )
+elseif (BUILD_SHARED_LIBS OR LINK_POLLY_INTO_TOOLS)
   target_link_libraries(Polly
----------------
`LINK_POLLY_INTO_TOOLS` should have no effect on how the Polly components are being built. If that linking into opt/bugpoint doesn't work, doesn't it mean that the Polly libs where built incorrectly in the first place? Assuming a downstream projects links Polly into their tool (say, "mollycc"), how would they link Polly into it without `LLVM_POLLY_LINK_INTO_TOOLS` which might be unwanted?

I suggest to always call these `target_link_libraries` (except if `LLVM_LINK_LLVM_DYLIB`, which get priority), assuming it is only redundant to do so if not `BUILD_SHARED_LIBS`. If that, as you mentioned, would break LLVMPolly, we might need to split Polly into 3 libraries:

- PollyImpl, containing all sources, but no dependencies
- Polly, depends on PollyImpl an its library dependencies, for linking by cmake.
- LLVMPolly, depends on PollyImpl only, for loading using `-load`


https://reviews.llvm.org/D24442





More information about the llvm-commits mailing list