OSDN Git Service

cmake: Add a flag to enable LTO
authorJustin Bogner <mail@justinbogner.com>
Thu, 4 Feb 2016 07:28:30 +0000 (07:28 +0000)
committerJustin Bogner <mail@justinbogner.com>
Thu, 4 Feb 2016 07:28:30 +0000 (07:28 +0000)
This adds -DLLVM_ENABLE_LTO, rather than forcing people to manually
add -flto to the various _FLAGS variables.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259766 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/modules/HandleLLVMOptions.cmake
docs/CMake.rst

index 9b6a590..99b2318 100644 (file)
@@ -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)
index 4e5feae..6d61442 100644 (file)
@@ -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.