[llvm] r259766 - cmake: Add a flag to enable LTO

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 3 23:28:30 PST 2016


Author: bogner
Date: Thu Feb  4 01:28:30 2016
New Revision: 259766

URL: http://llvm.org/viewvc/llvm-project?rev=259766&view=rev
Log:
cmake: Add a flag to enable LTO

This adds -DLLVM_ENABLE_LTO, rather than forcing people to manually
add -flto to the various _FLAGS variables.

Modified:
    llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
    llvm/trunk/docs/CMake.rst

Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=259766&r1=259765&r2=259766&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Thu Feb  4 01:28:30 2016
@@ -656,6 +656,13 @@ append_if(LLVM_BUILD_INSTRUMENTED "-fpro
   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)

Modified: llvm/trunk/docs/CMake.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CMake.rst?rev=259766&r1=259765&r2=259766&view=diff
==============================================================================
--- llvm/trunk/docs/CMake.rst (original)
+++ llvm/trunk/docs/CMake.rst Thu Feb  4 01:28:30 2016
@@ -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.
 




More information about the llvm-commits mailing list