Linking in clang on Windows

Using clang on Windows what program is supposed to be called to do the link step after compilation ?

In the Boost toolset for clang, admittedly created for clang on Linux, it appears that the program "link.exe" is being called. But when I build clang from the latest source for Windows using the VS2010 solution there is no program called "link.exe" being put in the bin/release directory. I do see a program called "llvm-link.exe" in the bin/release directory. Is that the linker that should be invoked ?

One has to use the link.exe that comes with Visual Studio.

There is work in progress to build a Windows-compatible linker based
on LLVM, called lld (http://lld.llvm.org/), but it's not ready yet.

Thanks,
Hans

Using clang on Windows what program is supposed to be called to do the link
step after compilation ?

One has to use the link.exe that comes with Visual Studio.

And how does clang find that link.exe on Windows ? Is it expected that the end-user must put it somewhere on his PATH ? Is the end-user supposed to be running clang from the command line within a VC++ CoMmand Prompt ( vcvarsall.bat setup ) ?

BTW is there any documentation anywhere on a web page about running clang on Windows ?

There is work in progress to build a Windows-compatible linker based
on LLVM, called lld (http://lld.llvm.org/), but it's not ready yet.

Thanks for the info.

Using clang on Windows what program is supposed to be called to do the
link
step after compilation ?

One has to use the link.exe that comes with Visual Studio.

And how does clang find that link.exe on Windows ? Is it expected that the
end-user must put it somewhere on his PATH ? Is the end-user supposed to be
running clang from the command line within a VC++ CoMmand Prompt (
vcvarsall.bat setup ) ?

Yes, that's the best way to run it currently.

BTW is there any documentation anywhere on a web page about running clang on
Windows ?

I have a patch that adds documentation about clang-cl. It should land today.

Thanks,
Hans

Here are the docs I was referring to:
http://clang.llvm.org/docs/UsersManual.html#clang-cl

Cheers,
Hans

Thanks very much. In Boost I am going to try to get one of the Boost Build experts to create a toolset for clang in Windows which invokes clang-cl from within a Visual Studio command prompt. Barring that I will have to figure out how to create the toolset myself, although I am far from a Boost Build expert.

I am assuming that clang in Windows should work from the VS2012 command prompt.

Edward Diener <eldlistmailingz@tropicsoft.com>
writes:

[snip]

I am assuming that clang in Windows should work from the VS2012
command prompt.

For some definition of "work". For C++ development, Clang+VS has a long
way to go to attain alpha stage, IMO. Clang+MinGW is more mature, but
some common features are still missing.

Edward Diener <eldlistmailingz@tropicsoft.com>
writes:

[snip]

I am assuming that clang in Windows should work from the VS2012
command prompt.

For some definition of "work".

By work I merely meant "compile and link so that the proper executables to do so are found". I realize there is still a way to go which is why I am trying to contribute some test/fixes from the Boost side, and report/discuss any problems I find.

For C++ development, Clang+VS has a long
way to go to attain alpha stage, IMO. Clang+MinGW is more mature, but
some common features are still missing.

I am working with Clang+VS. I use MingW with gcc under Windows but I would really like to see clang work natively from a Windows command prompt, not a MingW console.

Edward Diener <eldlistmailingz@tropicsoft.com>
writes:

I am working with Clang+VS. I use MingW with gcc under Windows but I
would really like to see clang work natively from a Windows command
prompt, not a MingW console.

FYI: mingw works fine from a Windows command prompt. The executables
that comprise the MinGW toolset are as native as cl.exe. BTW, there is
no such thing as a MinGW console.

I guess he is talking about Mingw runtime, Indeed, I also looking for
clang + Windows SDK + ms c runtime vs clang + mingw runtime.

"罗勇刚(Yonggang Luo)"
<luoyonggang@gmail.com> writes:

I guess he is talking about Mingw runtime, Indeed, I also looking for
clang + Windows SDK + ms c runtime vs clang + mingw runtime.

MinGW runtime is the MS runtime plus some additions (some C99 functions
and replacements for old/buggy functions.) The MS C runtime (and the VC
compiler) is seriously lacking on terms of C standards compliance.

MingW does provide a MingW shell, which is what I meant by the "MingW console" but as you have pointed out it does not need the shell to execute its output.

Edward Diener <eldlistmailingz@tropicsoft.com>
writes:

MingW does provide a MingW shell,

Possibly you are referring to the MSYS shell. MSYS is a Cygwin fork
which is completely unnecesary for using the MinGW toolset as a Windows
compiler.

[snip]

Visual Studio 2013 improves C99 support:

http://blogs.msdn.com/b/vcblog/archive/2013/07/19/c99-library-support-in-visual-studio-2013.aspx

http://blogs.msdn.com/b/vcblog/archive/2013/06/28/c-11-14-stl-features-fixes-and-breaking-changes-in-vs-2013.aspx

do note that the *l math functions are actually double as long double is 64 bit in Visual C++ so alternative functions would still be needed in MingW.

Yaron

You are right, but if I want to build clang under Windows using a Unix-like system do I not have to use this shell ( or cygwin itself ) ?

Edward Diener <eldlistmailingz@tropicsoft.com>
writes:

You are right, but if I want to build clang under Windows using a
Unix-like system do I not have to use this shell ( or cygwin itself )
?

Why do you want to build Clang under Windows using a Unix-like system?

It is perfectly possible to build Clang with MinGW without MSYS. I'll
say it is easier: just use CMake + Ninja from a Windows prompt. The same
method works for VS and most other (possibly all) OS/toolset
combinations.

OK, I will look into this on Windows also.

What I am understanding is that I can build clang either to work with
the MingW RTL or the VC++ RTL on Windows. Up to now I have been
concentrating on using clang with the VC++ RTL.

I am trying to use Boost with clang on Windows. This means using Boost
Build, which also means using a clang toolset which will work in at
least setting up clang to compile and link Boost libraries.

MingW does not have a full runtime of its own. The MingW RTL is MSVC runtime + additions and replacements.

  MingW does not have a full runtime of its own. The MingW RTL is MSVC
runtime + additions and replacements.

Thanks for the clarification.

With what version of VC++ is clang in Windows trying to be compatible ? Is it whatever version is used to build clang from the Visual Studio IDE ?