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

            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: unassignedclangb...@nondot.org
          Reporter: andreas.haferb...@gmx.de
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to