2013-01-15 10:00:59 +08:00
|
|
|
======
|
|
|
|
Driver
|
|
|
|
======
|
|
|
|
|
2017-02-24 12:31:08 +08:00
|
|
|
Note: this document discuss Mach-O port of LLD. For ELF and COFF,
|
|
|
|
see :doc:`index`.
|
|
|
|
|
2013-01-15 10:00:59 +08:00
|
|
|
.. contents::
|
|
|
|
:local:
|
|
|
|
|
|
|
|
Introduction
|
|
|
|
============
|
|
|
|
|
|
|
|
This document describes the lld driver. The purpose of this document is to
|
|
|
|
describe both the motivation and design goals for the driver, as well as details
|
|
|
|
of the internal implementation.
|
|
|
|
|
|
|
|
Overview
|
|
|
|
========
|
|
|
|
|
|
|
|
The lld driver is designed to support a number of different command line
|
2013-04-05 02:59:24 +08:00
|
|
|
interfaces. The main interfaces we plan to support are binutils' ld, Apple's
|
|
|
|
ld, and Microsoft's link.exe.
|
2013-01-15 10:00:59 +08:00
|
|
|
|
|
|
|
Flavors
|
|
|
|
-------
|
|
|
|
|
2013-02-03 15:05:26 +08:00
|
|
|
Each of these different interfaces is referred to as a flavor. There is also an
|
2014-01-27 11:09:26 +08:00
|
|
|
extra flavor "core" which is used to exercise the core functionality of the
|
2013-04-05 02:59:24 +08:00
|
|
|
linker it the test suite.
|
2013-01-15 10:00:59 +08:00
|
|
|
|
2013-04-05 02:59:24 +08:00
|
|
|
* gnu
|
|
|
|
* darwin
|
2013-01-15 10:00:59 +08:00
|
|
|
* link
|
|
|
|
* core
|
|
|
|
|
|
|
|
Selecting a Flavor
|
|
|
|
^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
There are two different ways to tell lld which flavor to be. They are checked in
|
|
|
|
order, so the second overrides the first. The first is to symlink :program:`lld`
|
|
|
|
as :program:`lld-{flavor}` or just :program:`{flavor}`. You can also specify
|
|
|
|
it as the first command line argument using ``-flavor``::
|
|
|
|
|
2013-04-05 02:59:24 +08:00
|
|
|
$ lld -flavor gnu
|
2013-01-15 10:00:59 +08:00
|
|
|
|
|
|
|
There is a shortcut for ``-flavor core`` as ``-core``.
|
|
|
|
|
|
|
|
|
2013-04-05 02:59:24 +08:00
|
|
|
Adding an Option to an existing Flavor
|
|
|
|
======================================
|
2013-01-15 10:00:59 +08:00
|
|
|
|
|
|
|
#. Add the option to the desired :file:`lib/Driver/{flavor}Options.td`.
|
|
|
|
|
2013-08-07 06:31:59 +08:00
|
|
|
#. Add to :cpp:class:`lld::FlavorLinkingContext` a getter and setter method
|
2013-04-05 02:59:24 +08:00
|
|
|
for the option.
|
2014-01-27 11:09:26 +08:00
|
|
|
|
2013-04-05 02:59:24 +08:00
|
|
|
#. Modify :cpp:func:`lld::FlavorDriver::parse` in :file:
|
|
|
|
`lib/Driver/{Flavor}Driver.cpp` to call the targetInfo setter
|
|
|
|
for corresponding to the option.
|
2013-01-15 10:00:59 +08:00
|
|
|
|
2013-04-05 02:59:24 +08:00
|
|
|
#. Modify {Flavor}Reader and {Flavor}Writer to use the new targtInfo option.
|
2013-01-15 10:00:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
Adding a Flavor
|
|
|
|
===============
|
|
|
|
|
|
|
|
#. Add an entry for the flavor in :file:`include/lld/Driver/Driver.h` to
|
2013-04-05 02:59:24 +08:00
|
|
|
:cpp:class:`lld::UniversalDriver::Flavor`.
|
2013-01-15 10:00:59 +08:00
|
|
|
|
2013-04-05 02:59:24 +08:00
|
|
|
#. Add an entry in :file:`lib/Driver/UniversalDriver.cpp` to
|
2014-01-27 11:09:26 +08:00
|
|
|
:cpp:func:`lld::Driver::strToFlavor` and
|
2013-04-05 02:59:24 +08:00
|
|
|
:cpp:func:`lld::UniversalDriver::link`.
|
2016-07-21 10:27:05 +08:00
|
|
|
This allows the flavor to be selected via symlink and `-flavor`.
|
2013-01-15 10:00:59 +08:00
|
|
|
|
|
|
|
#. Add a tablegen file called :file:`lib/Driver/{flavor}Options.td` that
|
|
|
|
describes the options. If the options are a superset of another driver, that
|
|
|
|
driver's td file can simply be included. The :file:`{flavor}Options.td` file
|
2013-02-03 15:05:26 +08:00
|
|
|
must also be added to :file:`lib/Driver/CMakeLists.txt`.
|
2013-01-15 10:00:59 +08:00
|
|
|
|
|
|
|
#. Add a ``{flavor}Driver`` as a subclass of :cpp:class:`lld::Driver`
|
2014-01-27 11:09:26 +08:00
|
|
|
in :file:`lib/Driver/{flavor}Driver.cpp`.
|