Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit cfb459a

Browse files
bognergottesmm
authored andcommitted
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259766 91177308-0d34-0410-b5e6-96231b3b80d8 (cherry picked from commit 125c546)
1 parent 752e143 commit cfb459a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

cmake/modules/HandleLLVMOptions.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,13 @@ append_if(LLVM_BUILD_INSTRUMENTED "-fprofile-instr-generate"
635635
CMAKE_EXE_LINKER_FLAGS
636636
CMAKE_SHARED_LINKER_FLAGS)
637637

638+
option(LLVM_ENABLE_LTO "Enable link-time optimization" OFF)
639+
append_if(LLVM_ENABLE_LTO "-flto"
640+
CMAKE_CXX_FLAGS
641+
CMAKE_C_FLAGS
642+
CMAKE_EXE_LINKER_FLAGS
643+
CMAKE_SHARED_LINKER_FLAGS)
644+
638645
# Plugin support
639646
# FIXME: Make this configurable.
640647
if(WIN32 OR CYGWIN)

docs/CMake.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ LLVM-specific variables
347347
are ``Address``, ``Memory``, ``MemoryWithOrigins``, ``Undefined``, ``Thread``,
348348
and ``Address;Undefined``. Defaults to empty string.
349349

350+
**LLVM_ENABLE_LTO**:BOOL
351+
Add the ``-flto`` flag to the compile and link command lines,
352+
enabling link-time optimization. Defaults to OFF.
353+
350354
**LLVM_PARALLEL_COMPILE_JOBS**:STRING
351355
Define the maximum number of concurrent compilation jobs.
352356

0 commit comments

Comments
 (0)