Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does clang/llvm on windows require Visual Studio's Link.exe?

According to LLVM's Getting Started (Windows) site:

... Clang can be used to emit bitcode, directly emit object files or even linked executables using Visual Studio’s link.exe.

Why is the use of Link.exe on Windows necessary? And, for that matter, what is used on Mac/Linux? Further down it says:

Compile the program to object code using the LLC code generator:
    C:\..> llc -filetype=obj hello.bc
Link to binary using Microsoft link:
    C:\..> link hello.obj -defaultlib:libcmt

Why can't LLC perform that last step? LLI seems to work fine so I assume that it interoperates with link.exe somehow under the hood - why can't LLC?

like image 727
Ephemera Avatar asked Jan 14 '13 04:01

Ephemera


People also ask

How do I run Clang in Visual Studio?

Set a custom LLVM toolset version in the IDE For more information, see Set C++ compiler and build properties. Select the Configuration Properties > General property page. Modify the Platform Toolset property to LLVM (clang-cl), if it isn't already set. Choose Apply to save your changes.

Does Clang need MSVC?

By default, Clang uses the target x86_64-pc-windows-msvc when compiling on Windows. With this target, Clang will look for Microsoft's msvc linker on PATH and use it for linking. If you want to go that route, install Microsoft Visual Studio.


2 Answers

Because no one has written a linker for LLVM.

There is a project to do so (called, unimaginatively lld) but it's not ready yet.

See http://lld.llvm.org for more details.

On the mac, people use Apple's linker, ld.

On Linux, most people use the gnu linker, usually (also) named ld

like image 163
Marshall Clow Avatar answered Nov 03 '22 01:11

Marshall Clow


Try MinGW-W64's ld. I've been using it with llvm's clang instead of VS tools that I used for building clang in the first place.

like image 44
Chawathe Vipul S Avatar answered Nov 03 '22 01:11

Chawathe Vipul S