[llvm-dev] How/Why are libraries in LLVM_LINK_COMPONENTS ordered/repeated for correct linking ? How can I include a tool's dependency's dependences in it ?

SANJAY SRIVALLABH SINGAPURAM via llvm-dev llvm-dev at lists.llvm.org
Mon Apr 24 00:32:56 PDT 2017


Hello,

I'd like to understand how CMake orders the libraries in
LLVM_LINK_COMPONENTS for proper linking in the build command, and
especially why it repeats some of them. This is in the context of a patch
to link NVPTX libraries into bugpoint (D32003
<https://reviews.llvm.org/D32003>) for Polly when
LLVM_POLLY_LINK_INTO_TOOLS=ON and POLLY_ENABLE_GPGPU_CODEGEN=ON.

This patch D31859 <https://reviews.llvm.org/D31859> initialises the NVPTX
backend within Polly when POLLY_ENABLE_GPGPU_CODEGEN=ON and requires the
NVPTX libraries to be linked into the application or library that also
links to Polly, e.g. opt, bugpoint. opt already links to the backend by
adding ${LLVM_TARGETS_TO_BUILD} to LLVM_LINK_COMPONENTS. I had attempted to
link NVPTX into bugpoint in similar ways (D32003#728913
<https://reviews.llvm.org/D32003#728913>) and the build kept failing,
before finding out that add_llvm_tool was linking the libraries in
LLVM_LINK_COMPONENTS to bugpoint. It seemed that CMake was processing
LLVM_LINK_COMPONENTS on bugpoint's files before it did on Polly, and hence
optimised out COMPONENTS (e.g. NVPTX) which weren't required by bugpoint
although required by Polly. Please correct me if I'm wrong here.

Is it possible to indicate to CMake to delay ordering the libraries in
LLVM_LINK_COMPONENTS till Polly is linked to bugpoint ?
Or link Polly to bugpoint before the LINK_COMPONENTS ?
Or link NVPTX to bugpoint even if it didn't contain any calls to the NVPTX
back-end (like -Wl,--no-as-needed) ?

Previous versions <https://reviews.llvm.org/D32003#725937> of the
patch had target_link_libraries(
bugpoint LLVMNVPTXTargetInfo ...) right after target_link_libraries(
bugpoint Polly) which did the job, but I was asked find a less complicated
way of accomplishing the same thing.

It was interesting to find to some of the libraries repeated in the build
command <https://reviews.llvm.org/D32003#728913>. Can anyone help me
understand why this is the case ?

Thank You,
Sanjay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170424/efcb8ad3/attachment.html>


More information about the llvm-dev mailing list