Skip to content

Commit 8190e09

Browse files
authored
[docs][NFC] Add usage instructions for FatLTO (#75853)
We included these in the commit message when we added `-ffat-lto-objects`, but they should be in the documentation as well.
1 parent a5a17e8 commit 8190e09

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

llvm/docs/FatLTO.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,40 @@ Supported File Formats
7676
The current implementation only supports ELF files. At time of writing, it is
7777
unclear if it will be useful to support other object file formats like ``COFF``
7878
or ``Mach-O``.
79+
80+
Usage
81+
=====
82+
83+
Clang users can specify ``-ffat-lto-objects`` with ``-flto`` or ``-flto=thin``.
84+
Without the ``-flto`` option, ``-ffat-lto-objects`` has no effect.
85+
86+
Compile an object file using FatLTO:
87+
88+
.. code-block:: console
89+
90+
$ clang -flto -ffat-lto-objects example.c -c -o example.o
91+
92+
Link using the object code from the fat object without LTO. This turns
93+
``-ffat-lto-objects`` into a no-op, when ``-fno-lto`` is specified:
94+
95+
.. code-block:: console
96+
97+
$ clang -fno-lto -ffat-lto-objects -fuse-ld=lld example.o
98+
99+
Alternatively, you can omit any references to LTO with fat objects and retain standard linker behavior:
100+
101+
.. code-block:: console
102+
103+
$ clang -fuse-ld=lld example.o
104+
105+
Link using the LLVM bitcode from the fat object with Full LTO:
106+
107+
.. code-block:: console
108+
109+
$ clang -flto -ffat-lto-objects -fuse-ld=lld example.o # clang will pass --lto=full --fat-lto-objects to ld.lld
110+
111+
Link using the LLVM bitcode from the fat object with Thin LTO:
112+
113+
.. code-block:: console
114+
115+
$ clang -flto=thin -ffat-lto-objects -fuse-ld=lld example.o # clang will pass --lto=thin --fat-lto-objects to ld.lld

0 commit comments

Comments
 (0)