[llvm-bugs] [Bug 35120] New: clang-cl /MT results in linker error unless /link /DEFAULTLIB:LIBCMT.lib is added

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Oct 29 12:47:14 PDT 2017


            Bug ID: 35120
           Summary: clang-cl /MT results in linker error unless /link
                    /DEFAULTLIB:LIBCMT.lib is added
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Driver
          Assignee: unassignedclangbugs at nondot.org
          Reporter: andreas.haferburg at gmx.de
                CC: llvm-bugs at lists.llvm.org

Input .ll file:

> ; 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

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

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
> clang-cl.exe /Z7 /MT /o "%build_dir%\test.exe" "%build_dir%\test.ll" /link /DEFAULTLIB:LIBCMT.lib
it works fine.

link.exe says "Microsoft (R) Incremental Linker Version 14.00.23026.0".

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/20171029/d91404e3/attachment.html>

More information about the llvm-bugs mailing list