Skip to content

[docs][NFC] Add usage instructions for FatLTO #75853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions llvm/docs/FatLTO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,40 @@ Supported File Formats
The current implementation only supports ELF files. At time of writing, it is
unclear if it will be useful to support other object file formats like ``COFF``
or ``Mach-O``.

Usage
=====

Clang users can specify ``-ffat-lto-objects`` with ``-flto`` or ``-flto=thin``.
Without the ``-flto`` option, ``-ffat-lto-objects`` has no effect.

Compile an object file using FatLTO:

.. code-block:: console

$ clang -flto -ffat-lto-objects example.c -c -o example.o

Link using the object code from the fat object without LTO. This turns
``-ffat-lto-objects`` into a no-op, when ``-fno-lto`` is specified:

.. code-block:: console

$ clang -fno-lto -ffat-lto-objects -fuse-ld=lld example.o
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description can state that -ffat-lto-objects is a no-op for linking when -fno-lto is specified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.


Alternatively, you can omit any references to LTO with fat objects and retain standard linker behavior:

.. code-block:: console

$ clang -fuse-ld=lld example.o

Link using the LLVM bitcode from the fat object with Full LTO:

.. code-block:: console

$ clang -flto -ffat-lto-objects -fuse-ld=lld example.o # clang will pass --lto=full --fat-lto-objects to ld.lld

Link using the LLVM bitcode from the fat object with Thin LTO:

.. code-block:: console

$ clang -flto=thin -ffat-lto-objects -fuse-ld=lld example.o # clang will pass --lto=thin --fat-lto-objects to ld.lld