[llvm] [docs][NFC] Add usage instructions for FatLTO (PR #75853)

Paul Kirth via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 18 12:58:52 PST 2023


https://github.com/ilovepi created https://github.com/llvm/llvm-project/pull/75853

We included these in the commit message when we added `-ffat-lto-objects`, but they should be in the documentation as well.

>From a879e37daad6a1bec3c0b48215afd7e5e4394e9d Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Mon, 18 Dec 2023 12:54:29 -0800
Subject: [PATCH] [docs] Add usage instructions for FatLTO

We included these in the commit message when we added
`-ffat-lto-objects`, but they should be in the documentation as well.
---
 llvm/docs/FatLTO.rst | 53 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/llvm/docs/FatLTO.rst b/llvm/docs/FatLTO.rst
index 21da24504bcdf6..bc4051f2d9ec62 100644
--- a/llvm/docs/FatLTO.rst
+++ b/llvm/docs/FatLTO.rst
@@ -76,3 +76,56 @@ 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
+===========
+
+Users are expected to pass ``-ffat-lto-objects`` to clang in addition to one of
+the ``-flto`` variants. Without the ``-flto`` flag, ``-ffat-lto-objects`` has
+no effect.
+
+
+Compile and link. Use the object code from the fat object without LTO.
+
+.. code-block:: console
+
+   $ clang -fno-lto -ffat-lto-objects -fuse-ld=lld foo.c
+
+Compile and link. Select full LTO at link time.
+
+.. code-block:: console
+
+   $ clang -flto -ffat-lto-objects -fuse-ld=lld foo.c
+
+Compile and link. Select ThinLTO at link time.
+
+.. code-block:: console
+
+   $ clang -flto=thin -ffat-lto-objects -fuse-ld=lld foo.c
+
+Compile and link. Use ThinLTO with the UnifiedLTO pipeline.
+
+.. code-block:: console
+
+   $ clang -flto=thin -ffat-lto-objects -funified-lto -fuse-ld=lld foo.c
+
+Compile and link. Use full LTO  with the UnifiedLTO pipeline.
+
+.. code-block:: console
+
+   $ clang -flto -ffat-lto-objects -funified-lto -fuse-ld=lld foo.c
+
+Link separately, using ThinLTO.
+
+.. code-block:: console
+
+   $ clang -c -flto=thin -ffat-lto-objects foo.c
+   $ clang -flto=thin -fuse-ld=lld foo.o -ffat-lto-objects  # pass --lto=thin --fat-lto-objects to ld.lld
+
+Link separately, using full LTO.
+
+.. code-block:: console
+
+   $ clang -c -flto -ffat-lto-objects foo.c
+   $ clang -flto -fuse-ld=lld foo.o  # pass --lto=full --fat-lto-objects to ld.lld
+



More information about the llvm-commits mailing list