<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58015>58015</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            LLVM_LINK_LLVM_DYLIB=ON on windows breaks MLIR build
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          tobiasgrosser
      </td>
    </tr>
</table>

<pre>
    When building LLVM with MLIR enabled and using LLVM_LINK_LLVM_DYLIB=ON, I get a build failure in the linker:

```[ 81%] Linking CXX executable ../../../../bin/tblgen-lsp-server.exe
ld.lld: error: duplicate symbol: llvm::inconvertibleErrorCode()
>>> defined at libLLVMSupport.a(Error.cpp.obj)
>>> defined at libLLVM-15.dll
```

The full command line used is
```
cmake -G Ninja ../llvm -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/../../lean-llvm -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_USE_LINKER=lld \
    -DLLVM_ENABLE_PROJECTS="mlir;llvm;clang;lld;compiler-rt;libcxx;libcxxabi;libunwind" -DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_CCACHE_BUILD=ON\
    -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_LIBCXX=ON -DLLVM_ENABLE_FFI=OFF\
    `# https://boxbase.org/entries/2018/jun/11/minimal-llvm-build/`\
    -DLLVM_TARGETS_TO_BUILD='AArch64;WebAssembly;X86'\
    `# https://libcxx.llvm.org/BuildingLibcxx.html`\
    -DCLANG_DEFAULT_CXX_STDLIB=libc++ -DCLANG_DEFAULT_LINKER=lld -DCLANG_DEFAULT_RTLIB=compiler-rt -DLIBCXX_USE_COMPILER_RT=ON -DLIBCXXABI_USE_COMPILER_RT=ON -DLIBCXXABI_USE_LLVM_UNWINDER=ON -DLIBUNWIND_USE_COMPILER_RT=ON -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON\
    -DCOMPILER_RT_BUILD_SANITIZERS=OFF\
    `# hide libc++ symbols in libleanshared`\
    -DLIBCXX_HERMETIC_STATIC_LIBRARY=ON -DLIBCXXABI_HERMETIC_STATIC_LIBRARY=ON\
    -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON\
    -DCMAKE_SYSTEM_IGNORE_PATH=/usr/lib -DLLVM_HOST_TRIPLE=x86_64-w64-windows-gnu -DLLD_DEFAULT_LD_LLD_IS_MINGW=ON \
    -DLIBCXX_HAS_WIN32_THREAD_API=ON -DLIBCXXABI_HAS_WIN32_THREAD_API=ON -DLIBCXX_ENABLE_SHARED=OFF 
    -DLIBCXXABI_ENABLE_SHARED=OFF -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
    -G "Unix Makefiles"
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVttyokoU_Rp86ZLiEow--IBclDOIFpCjOS8Ul1Y7acDiMjF_f3bT6KgxM5MiCOxL71577QVJmX1ONwdcoKQlNCPFHrnuv0v0QZoDWrqOj3ARJxRnKC4y1NZnh8h1vB9Rd2W-us5MUM2VJygGctAeNyjm6dAuJrStMCIFag4YUVK840pQdUEyBel8Hkn9oc3QWBYUTdBM5IIrW8zYbhE-4bRtWBlIFAXFvjslpIBzk9A9Loa0Pg5rXP3ElQhhfAWaiZRmsCzCVVWy9VHWHilJ4waj-jNPSsqeUfozZ7WpOinSsoAUDYE1LRZjlBkWlLGgTPqiVYsfKMM7UjB8GthewhAJ2uOxrBoxhoAuWEyPR7FM3v4qeihrYkbpPTZXgIWA5K6lFKVlnrO2AKwYegNpSP0wLs3jd4yGc-SR4i3mILLdoqFpLPUfVjR7cVwzCl_XUJTpY4rjGl-MjheEuutGa9-ynS04CMrTemPe9AAiAPvrlEZkrJZrx7V8iEhpDL28mLbbL0ZBmcEBLh2nXgKr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