summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2016-02-08 21:01:24 +0000
committerJustin Bogner <mail@justinbogner.com>2016-02-08 21:01:24 +0000
commit9fd2039fafc9ef9f03efb4910099eef29871c993 (patch)
treeb7a74ddc050dd84220780cea114810912b7486dc
parenta3be895b6167f2694c1d4cd179cc90ba682230d9 (diff)
downloadbcm5719-llvm-9fd2039fafc9ef9f03efb4910099eef29871c993.tar.gz
bcm5719-llvm-9fd2039fafc9ef9f03efb4910099eef29871c993.zip
cmake: Accept "thin" or "full" as arguments to -DLLVM_ENABLE_LTO
Mehdi suggested in a review of r259766 that it's also useful to easily set the type of LTO. Augment the cmake variable to support that. llvm-svn: 260143
-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