<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_CONFIRMED "
   title="CONFIRMED - 43ceb74eb1a broke static LLVM extensions (e.g. Polly)"
   href="https://bugs.llvm.org/show_bug.cgi?id=49843">49843</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>43ceb74eb1a broke static LLVM extensions (e.g. Polly)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Build scripts
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>CONFIRMED
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>release blocker
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>cmake
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>raul@tambre.ee
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, tstellar@redhat.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>cmake ../llvm -GNinja \
        -DLLVM_BUILD_LLVM_DYLIB=ON \
        -DLLVM_ENABLE_PROJECTS="polly" \
        -DLLVM_TARGETS_TO_BUILD="X86"
ninja lib/libLLVM-13git.so

Fails with:
[1468/1468] Linking CXX shared library lib/libLLVM-13git.so
FAILED: lib/libLLVM-13git.so
[build command redacted as it's very long]
ld.lld: error: undefined symbol: getPollyPluginInfo()
<span class="quote">>>> referenced by Extension.def:2 (include/llvm/Support/Extension.def:2)
>>>               lib/Extensions/CMakeFiles/obj.LLVMExtensions.dir/Extensions.cpp.o:(llvm::details::extensions_anchor())
>>> referenced by Extension.def:2 (include/llvm/Support/Extension.def:2)
>>>               lib/LTO/CMakeFiles/obj.LLVMLTO.dir/LTOBackend.cpp.o:(RegisterPassPlugins(llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, llvm::PassBuilder&))</span >

I've bisected this to commit 43ceb74eb1a5801662419fb66a6bf0d5414f1ec5.

Observations:
* Reverting the change in llvm/tools/llvm-shlib/CMakeLists.txt bypasses the
issue.
* Passing -DLLVM_POLLY_LINK_INTO_TOOLS=OFF works around the issue.

I've added some debug prints and confirmed that obj.Polly target is being
created.
Dependency on Polly if it's static seems to be added in
function(process_llvm_pass_plugins) to LLVMExtensions's LINK_LIBRARIES through
LLVM_STATIC_EXTENSIONS.

I think the issue might be something to do with the fact if libLLVM is linked
against obj.LLVMExtensions it doesn't pull in Polly as no linking happens for
object libraries. But I'm not sure, as this is fairly complicated.

Cc @tstellar in case you don't mind fixing this.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>