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

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Nov 3 01:08:14 PDT 2017


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

Andreas Haferburg <andreas.haferburg at gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Andreas Haferburg <andreas.haferburg at gmx.de> ---
Aha! Alright, now I understand, thank you. If I emit the instructions for the
linker in the IR, I no longer need to specify it when calling link.exe or
clang-cl.exe.

> !llvm.linker.options = !{!1}
> !1 = !{!"/DEFAULTLIB:libcmt.lib"}

>From the perspective of a frontend author, I do find it very surprising to look
at .ll as .obj. clang.exe will produce an .obj file from the .ll file, so they
must be different. But I understand that the clang-cl driver's job is to
produce IR, so everything it does should be contained in the IR. I guess it's a
pitfall for frontend authors that can't be avoided.

I believe the main problem was that I couldn't figure out how to make
`clang-cl.exe` output IR, since `-S -emit-llvm` doesn't work with clang-cl.exe,
and none of the examples are written for clang-cl.exe. What I ended up doing is
call `clang-cl.exe -###` to find out what it actually does, and then replace
the `-emit-obj` with `-emit-llvm`, but that is very much non-obvious. So I
ended up looking at random hello_world.ll files that I found on the web, which
was a bad idea.

There is no `-emit-llvm` flag in gcc either. Why doesn't `/c -emit-llvm` work
with clang-cl.exe? I'll open a feature request.

-- 
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/20171103/7c4f539f/attachment.html>


More information about the llvm-bugs mailing list