xref: /freebsd-src/contrib/llvm-project/lld/docs/windows_support.rst (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
10b57cec5SDimitry Andric.. raw:: html
20b57cec5SDimitry Andric
30b57cec5SDimitry Andric  <style type="text/css">
40b57cec5SDimitry Andric    .none { background-color: #FFCCCC }
50b57cec5SDimitry Andric    .partial { background-color: #FFFF99 }
60b57cec5SDimitry Andric    .good { background-color: #CCFF99 }
70b57cec5SDimitry Andric  </style>
80b57cec5SDimitry Andric
90b57cec5SDimitry Andric.. role:: none
100b57cec5SDimitry Andric.. role:: partial
110b57cec5SDimitry Andric.. role:: good
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric===============
140b57cec5SDimitry AndricWindows support
150b57cec5SDimitry Andric===============
160b57cec5SDimitry Andric
170b57cec5SDimitry AndricLLD supports Windows operating system. When invoked as ``lld-link.exe`` or with
180b57cec5SDimitry Andric``-flavor link``, the driver for Windows operating system is used to parse
190b57cec5SDimitry Andriccommand line options, and it drives further linking processes. LLD accepts
200b57cec5SDimitry Andricalmost all command line options that the linker shipped with Microsoft Visual
210b57cec5SDimitry AndricC++ (link.exe) supports.
220b57cec5SDimitry Andric
230b57cec5SDimitry AndricThe current status is that LLD is used to link production builds of large
240b57cec5SDimitry Andricreal-world binaries such as Firefox and Chromium.
250b57cec5SDimitry Andric
260b57cec5SDimitry AndricDevelopment status
270b57cec5SDimitry Andric==================
280b57cec5SDimitry Andric
290b57cec5SDimitry AndricDriver
300b57cec5SDimitry Andric  :good:`Mostly done`. Some exotic command line options that are not usually
31480093f4SDimitry Andric  used for application development, such as ``/DRIVER``, are not supported.
320b57cec5SDimitry Andric
330b57cec5SDimitry AndricLinking against DLL
340b57cec5SDimitry Andric  :good:`Done`. LLD can read import libraries needed to link against DLL. Both
350b57cec5SDimitry Andric  export-by-name and export-by-ordinal are supported.
360b57cec5SDimitry Andric
370b57cec5SDimitry AndricLinking against static library
380b57cec5SDimitry Andric  :good:`Done`. The format of static library (.lib) on Windows is actually the
390b57cec5SDimitry Andric  same as on Unix (.a). LLD can read it.
400b57cec5SDimitry Andric
410b57cec5SDimitry AndricCreating DLL
420b57cec5SDimitry Andric  :good:`Done`. LLD creates a DLL if ``/DLL`` option is given. Exported
430b57cec5SDimitry Andric  functions can be specified either via command line (``/EXPORT``) or via
440b57cec5SDimitry Andric  module-definition file (.def). Both export-by-name and export-by-ordinal are
450b57cec5SDimitry Andric  supported.
460b57cec5SDimitry Andric
470b57cec5SDimitry AndricWindows resource files support
480b57cec5SDimitry Andric  :good:`Done`. If an ``.res`` file is given, LLD converts the file to a COFF
490b57cec5SDimitry Andric  file using LLVM's Object library.
500b57cec5SDimitry Andric
510b57cec5SDimitry AndricSafe Structured Exception Handler (SEH)
520b57cec5SDimitry Andric  :good:`Done` for both x86 and x64.
530b57cec5SDimitry Andric
540b57cec5SDimitry AndricModule-definition file
550b57cec5SDimitry Andric  :partial:`Partially done`. LLD currently recognizes these directives:
560b57cec5SDimitry Andric  ``EXPORTS``, ``HEAPSIZE``, ``STACKSIZE``, ``NAME``, and ``VERSION``.
570b57cec5SDimitry Andric
580b57cec5SDimitry AndricDebug info
590b57cec5SDimitry Andric  :good:`Done`.  LLD can emit PDBs that are at parity with those generated by
600b57cec5SDimitry Andric  link.exe.  However, LLD does not support /DEBUG:FASTLINK.
610b57cec5SDimitry Andric
620b57cec5SDimitry Andric
630b57cec5SDimitry AndricDownloading LLD
640b57cec5SDimitry Andric===============
650b57cec5SDimitry Andric
660b57cec5SDimitry AndricThe Windows version of LLD is included in the `pre-built binaries of LLVM's
670b57cec5SDimitry Andricreleases <https://releases.llvm.org/download.html>`_ and in the `LLVM Snapshot
680b57cec5SDimitry AndricBuilds <https://llvm.org/builds/>`_.
690b57cec5SDimitry Andric
700b57cec5SDimitry AndricBuilding LLD
710b57cec5SDimitry Andric============
720b57cec5SDimitry Andric
730b57cec5SDimitry AndricUsing Visual Studio IDE/MSBuild
740b57cec5SDimitry Andric-------------------------------
750b57cec5SDimitry Andric
760b57cec5SDimitry Andric1. Check out LLVM and LLD from the LLVM SVN repository (or Git mirror),
770b57cec5SDimitry Andric#. run ``cmake -G "Visual Studio 12" <llvm-source-dir>`` from VS command prompt,
780b57cec5SDimitry Andric#. open LLVM.sln with Visual Studio, and
790b57cec5SDimitry Andric#. build ``lld`` target in ``lld executables`` folder
800b57cec5SDimitry Andric
810b57cec5SDimitry AndricAlternatively, you can use msbuild if you don't like to work in an IDE::
820b57cec5SDimitry Andric
830b57cec5SDimitry Andric  msbuild LLVM.sln /m /target:"lld executables\lld"
840b57cec5SDimitry Andric
850b57cec5SDimitry AndricMSBuild.exe had been shipped as a component of the .NET framework, but since
860b57cec5SDimitry Andric2013 it's part of Visual Studio. You can find it at "C:\\Program Files
870b57cec5SDimitry Andric(x86)\\msbuild".
880b57cec5SDimitry Andric
890b57cec5SDimitry AndricYou can build LLD as a 64 bit application. To do that, open VS2013 x64 command
900b57cec5SDimitry Andricprompt and run cmake for "Visual Studio 12 Win64" target.
910b57cec5SDimitry Andric
920b57cec5SDimitry AndricUsing Ninja
930b57cec5SDimitry Andric-----------
940b57cec5SDimitry Andric
950b57cec5SDimitry Andric1. Check out LLVM and LLD from the LLVM SVN repository (or Git mirror),
960b57cec5SDimitry Andric#. run ``cmake -G ninja <llvm-source-dir>`` from VS command prompt,
970b57cec5SDimitry Andric#. run ``ninja lld``
98*5f757f3fSDimitry Andric
99*5f757f3fSDimitry AndricExtensions
100*5f757f3fSDimitry Andric==========
101*5f757f3fSDimitry Andric
102*5f757f3fSDimitry AndricLLD flags
103*5f757f3fSDimitry Andric---------
104*5f757f3fSDimitry Andric
105*5f757f3fSDimitry Andric* ``/build-id``: Always generate GUID hash. When PDB is generated, LLD uses PDB
106*5f757f3fSDimitry Andric  content hash for GUID. Otherwise, LLD uses output binary content hash for GUID.
107*5f757f3fSDimitry Andric  LLD also provides ``__buildid`` symbol pointing to the 16 bytes GUID hash if
108*5f757f3fSDimitry Andric  there is a reference to it.
109