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

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 8 10:14:16 PST 2016


> On Feb 8, 2016, at 10:10 AM, Justin Bogner <mail at justinbogner.com> wrote:
> 
> Mehdi AMINI <mehdi.amini at apple.com> writes:
>> joker.eph added a subscriber: joker.eph.
>> joker.eph added a comment.
> 
> Please keep patch review on-list. It seems whatever phabricator feature
> this is just sends personal emails in a new thread with no patch
> context. I've dug up the original thread and restored the context.

Good point...

> 
>> Could we support a string flag instead of a boolean? (I don't know if
>> CMake options can be enums)
>> The clang "-flto" accepts both "full" and "thin" as an argument, and
>> it would be nice to support it first class in the configuration.
> 
> This seems reasonable, but it would have to allow/use by default the
> form without an '=' so that this can be used with gcc as well.

Good point (as well)!

> I'm thinking something like -DLLVM_LTO_MODE={off,on,full,thin}. WDYT?

I don't have a better idea :)

CC Teresa who may have an opinion as she added the -flto=thin to clang.

Thanks,

-- 
Mehdi


> 
> Justin Bogner via llvm-commits <llvm-commits at lists.llvm.org> writes:
>> 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.
>> 
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list