[llvm-bugs] [Bug 41147] New: Visual Studio LLVM toolset uses "lib.exe" instead of "llvm-lib.exe"

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 19 16:01:48 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41147

            Bug ID: 41147
           Summary: Visual Studio LLVM toolset uses "lib.exe" instead of
                    "llvm-lib.exe"
           Product: new-bugs
           Version: 7.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: steven at uplinklabs.net
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190319/ef911022/attachment-0001.html>


More information about the llvm-bugs mailing list