Bug ID: 41147
           Summary: Visual Studio LLVM toolset uses "lib.exe" instead of
           Product: new-bugs
           Version: 7.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs

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
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)' !=
+    <LlvmLibExecutable>$(LLVMInstallDir)bin\llvm-lib.exe</LlvmLibExecutable>
+    <UseLlvmLib>true</UseLlvmLib>

   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.WindowsSDK.props"
diff --git a/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>


Adding the above allowed my .lib with LTO objects to be created properly.

You are receiving this mail because:
You are on the CC list for the bug.
llvm-bugs mailing list

Reply via email to