<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_NEW "
   title="NEW - Visual Studio LLVM toolset uses "lib.exe" instead of "llvm-lib.exe""
   href="https://bugs.llvm.org/show_bug.cgi?id=41147">41147</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Visual Studio LLVM toolset uses "lib.exe" instead of "llvm-lib.exe"
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>steven@uplinklabs.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This affects at least LLVM 7.0 onwards, through trunk.

I noticed that when I compiled objects with "clang-cl -flto", it wasn't able to
create a static library with them. It was apparently using the Visual Studio
provided "lib.exe", which doesn't understand these objects and just spits out
an error message:

foo.obj : fatal error LNK1107: invalid or corrupt file: cannot read at 0x1A4C

It looks like the LLVM.Cpp.Common.{props,targets} files are missing a tool
executable definition for llvm-lib.exe:


diff --git a/tools/msbuild/LLVM.Cpp.Common.props
b/tools/msbuild/LLVM.Cpp.Common.props
index 3420b77cfff..bc021b3b9e1 100644
--- a/tools/msbuild/LLVM.Cpp.Common.props
+++ b/tools/msbuild/LLVM.Cpp.Common.props
@@ -42,8 +42,10 @@
     <LLVMInstallDir Condition="'$(LLVMInstallDir)' !=
''">$(LLVMInstallDir)\</LLVMInstallDir>
     <ClangClExecutable>$(LLVMInstallDir)bin\clang-cl.exe</ClangClExecutable>
     <LldLinkExecutable>$(LLVMInstallDir)bin\lld-link.exe</LldLinkExecutable>
+    <LlvmLibExecutable>$(LLVMInstallDir)bin\llvm-lib.exe</LlvmLibExecutable>
     <UseClangCl>true</UseClangCl>
     <UseLldLink>true</UseLldLink>
+    <UseLlvmLib>true</UseLlvmLib>
   </PropertyGroup>

   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.WindowsSDK.props"
Condition="Exists('$(VCTargetsPath)\Microsoft.Cpp.WindowsSDK.props')"/>
diff --git a/tools/msbuild/LLVM.Cpp.Common.targets
b/tools/msbuild/LLVM.Cpp.Common.targets
index 5870a3d4c59..74a98d6439b 100644
--- a/tools/msbuild/LLVM.Cpp.Common.targets
+++ b/tools/msbuild/LLVM.Cpp.Common.targets
@@ -9,6 +9,7 @@
          that the user may have overridden in the UI. -->
     <CLToolExe Condition="$(UseClangCl)">$(ClangClExecutable)</CLToolExe>
     <LinkToolExe Condition="$(UseLldLink)">$(LldLinkExecutable)</LinkToolExe>
+    <LIBToolExe Condition="$(UseLlvmLib)">$(LlvmLibExecutable)</LIBToolExe>
   </PropertyGroup>

   <ItemGroup>


Adding the above allowed my .lib with LTO objects to be created properly.</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>