summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/cmake/modules/HandleLLVMOptions.cmake7
-rw-r--r--llvm/docs/CMake.rst4
2 files changed, 11 insertions, 0 deletions
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 9b6a590920e..99b23180bbb 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -656,6 +656,13 @@ 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)
+
# Plugin support
# FIXME: Make this configurable.
if(WIN32 OR CYGWIN)
diff --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst
index 4e5feae9993..6d61442ed97 100644
--- a/llvm/docs/CMake.rst
+++ b/llvm/docs/CMake.rst
@@ -347,6 +347,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_PARALLEL_COMPILE_JOBS**:STRING
Define the maximum number of concurrent compilation jobs.
OpenPOWER on IntegriCloud