<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 - clang-cl /MT results in linker error unless /link /DEFAULTLIB:LIBCMT.lib is added"
   href="https://bugs.llvm.org/show_bug.cgi?id=35120">35120</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-cl /MT results in linker error unless /link /DEFAULTLIB:LIBCMT.lib is added
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>5.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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Driver
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>andreas.haferburg@gmx.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Input .ll file:

<span class="quote">> ; ModuleID = 'D:\dropbox\proj\dkmv\tests\test.dkf'
> source_filename = "D:\5Cdropbox\5Cproj\5Cdkmv\5Ctests\5Ctest.dkf"
> target triple = "x86_64-pc-windows-msvc19.0.23026"
> define i32 @main(i8*) {
>   call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @lit1, i32 0, i32 0))
>   ret i32 0
> }
> @lit1 = internal constant [13 x i8] c"Hello World!\00"
> declare i32 @puts(i8*) nounwind</span >


Building with
<span class="quote">> clang-cl.exe /MT /o "%build_dir%\test.exe" "%build_dir%\test.ll"</span >
results in errors:
<span class="quote">> test-845194.obj : error LNK2019: unresolved external symbol puts referenced in function main
> LINK : error LNK2001: unresolved external symbol mainCRTStartup</span >

Looking at the output of -###, it does add "-D_MT" and
"--dependent-lib=libcmt". I believe the idea is that the dependency on libcmt
is written to the .obj file. But the linker doesn't seem to pick it up.

If I build with
<span class="quote">> clang-cl.exe /Z7 /MT /o "%build_dir%\test.exe" "%build_dir%\test.ll" /link /DEFAULTLIB:LIBCMT.lib</span >
it works fine.

link.exe says "Microsoft (R) Incremental Linker Version 14.00.23026.0".</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>