summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/cmake/modules/HandleLLVMOptions.cmake18
-rw-r--r--llvm/docs/CMake.rst7
2 files changed, 16 insertions, 9 deletions
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 99b23180bbb..8156e8c83ae 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -656,12 +656,18 @@ append_if(LLVM_BUILD_INSTRUMENTED "-fprofile-instr-generate"
CMAKE_EXE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS)
-option(LLVM_ENABLE_LTO "Enable link-time optimization" OFF)
-append_if(LLVM_ENABLE_LTO "-flto"
- CMAKE_CXX_FLAGS
- CMAKE_C_FLAGS
- CMAKE_EXE_LINKER_FLAGS
- CMAKE_SHARED_LINKER_FLAGS)
+option(LLVM_ENABLE_LTO "Build LLVM with LTO. May be specified as Thin or Full to use a particular kind of LTO" OFF)
+string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO)
+if(uppercase_LLVM_ENABLE_LTO STREQUAL "THIN")
+ append("-flto=thin" CMAKE_CXX_FLAGS CMAKE_C_FLAGS
+ CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
+elseif(uppercase_LLVM_ENABLE_LTO STREQUAL "FULL")
+ append("-flto=full" CMAKE_CXX_FLAGS CMAKE_C_FLAGS
+ CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
+elseif(LLVM_ENABLE_LTO)
+ append("-flto" CMAKE_CXX_FLAGS CMAKE_C_FLAGS
+ CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
+endif()
# Plugin support
# FIXME: Make this configurable.
diff --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst
index 12d74ace161..879e4627e41 100644
--- a/llvm/docs/CMake.rst
+++ b/llvm/docs/CMake.rst
@@ -351,9 +351,10 @@ LLVM-specific variables
are ``Address``, ``Memory``, ``MemoryWithOrigins``, ``Undefined``, ``Thread``,
and ``Address;Undefined``. Defaults to empty string.
-**LLVM_ENABLE_LTO**:BOOL
- Add the ``-flto`` flag to the compile and link command lines,
- enabling link-time optimization. Defaults to OFF.
+**LLVM_ENABLE_LTO**:STRING
+ Add ``-flto`` or ``-flto=`` flags to the compile and link command
+ lines, enabling link-time optimization. Possible values are ``Off``,
+ ``On``, ``Thin`` and ``Full``. Defaults to OFF.
**LLVM_PARALLEL_COMPILE_JOBS**:STRING
Define the maximum number of concurrent compilation jobs.
OpenPOWER on IntegriCloud