Is there a separate linker for LLVM in Windows?

I just found that some samples used link.exe from Visual Studio to generate the final image, does LLVM has a replacement for link.exe to generate the final binary?

Hello

I just found that some samples used link.exe from Visual Studio to generate
the final image, does LLVM has a replacement for link.exe to generate the
final binary?

No. You need to use your own platform linker.

Not currently, but a linker is being worked on.

Is there any reason why link.exe is undesirable? You can also use ld from MinGW.

- Michael Spencer

I just found that some samples used link.exe from Visual Studio to generate
the final image, does LLVM has a replacement for link.exe to generate the
final binary?

I'm not related to the topic starter, but I see at least one huge
disadvantage of the dependency on link.exe.
W/o such a dependency it would be possible reliably generate Windows
executables on Linux or Mac, which has its own benefits (e.g.
distributed compilation)

krasin

Not currently, but a linker is being worked on.

Can you elaborate on this? I recall seeing a dev-meeting presentation
mentioning this, but not much more. Is there more information
available online about this effort?
Eli

GRUB, the Grand Unified Build that the Lilypond music engraving system
uses does something like that.

If you build the GNU Binutils in a cross-compilation mode you can do that.

Our examples ought to at least mention that one can use Gnu ld on any
platform that ld runs on to link executables for any platform it
generates binraries for.

Even better would be to provide instructions for building such a
cross-linker. I'd love to write those instructions myself it but I've
got a lot on my plate right now.

Don Quixote de la Mancha <quixote@dulcineatech.com> writes:

Or just get it from your Linux distro.

I didn't realize. That's Just Dandy.

For instance, the
mingw32-binutils package in Debian-based distros will provide a nice
`ld' for cross-compiling to Windows.

One Mac OS X there are various i386-mingw32 packages in MacPorts:

http://www.macports.org/ports.php?by=name&substr=mingw

Here are the MacPorts installation instructions:

Fedora has a lot of packages that have been built with MingW:

https://admin.fedoraproject.org/pkgdb/acls/list/?searchwords=mingw32*

There doesn't seem to be a 64-bit port of MingW yet. I would expect
GNU Binutils to support 64-bit Windows if you built its source
yourself - is that the case?

The key part of MingW that makes Windows development possible on so
many other platforms is that they have written their own Win32 header
files and C runtime library. That way one does not need a Visual
Studio license to use its library and headers.

To do 64-bit development on Windows completely without Visual Studio,
one would need those headers.

However, there is a "Lite" version of Visual Studio that Microsoft
distributes for free. If it includes the 64-bit headers one could use
those until MingW completes its 64-bit support.

It provides both 32-bit and 64-bit (cross)compilers.

Best regards,
--Edwin

Don Quixote de la Mancha <quixote@dulcineatech.com> writes:

[snip]

There doesn't seem to be a 64-bit port of MingW yet. I would expect
GNU Binutils to support 64-bit Windows if you built its source
yourself - is that the case?

There are Debian pacakges for MinGW-64. I don't know if you can build
your own from Binutils sources or need to patch them.

The key part of MingW that makes Windows development possible on so
many other platforms is that they have written their own Win32 header
files and C runtime library.

Header files, yes. C runtime library, no. Just the imports library,
which is enough.

That way one does not need a Visual
Studio license to use its library and headers.

To do 64-bit development on Windows completely without Visual Studio,
one would need those headers.

However, there is a "Lite" version of Visual Studio that Microsoft
distributes for free. If it includes the 64-bit headers one could use
those until MingW completes its 64-bit support.

AFAIK, you can do 64 bit Windows development (including cross-compiling)
with MinGW alone. Maybe it doesn't include 100% of the Windows SDK, but
should be enough for most cases.

So, back on topic, it is possible to link object files generated with
LLVM without resorting to Microsoft's linker. And it is possible to link
Windows applications on other systems too, all thanks to MinGW's `ld'.