<div dir="ltr">I've submitted r200745, which is probably a better fix.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 4, 2014 at 11:47 AM, Evgeniy Stepanov <span dir="ltr"><<a href="mailto:eugeni.stepanov@gmail.com" target="_blank">eugeni.stepanov@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Well, it's not that easy. Nothing is easy with cmake. I'll try some<br>
more today, and either fix or revert the change.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Tue, Feb 4, 2014 at 1:49 AM, Justin Bogner <<a href="mailto:mail@justinbogner.com">mail@justinbogner.com</a>> wrote:<br>
> Evgeniy Stepanov <<a href="mailto:eugeni.stepanov@gmail.com">eugeni.stepanov@gmail.com</a>> writes:<br>
>> Don't use -ffunction-sections if -fno-function-sections is not<br>
>> supported in the compiler.<br>
>><br>
>> This will disable -ffunction-sections in older versions of Clang where it<br>
>> breaks build of sanitizer runtime library.<br>
>><br>
>> Modified:<br>
>>     llvm/trunk/cmake/modules/HandleLLVMOptions.cmake<br>
>><br>
>> Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=200695&r1=200694&r2=200695&view=diff==============================================================================" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=200695&r1=200694&r2=200695&view=diff==============================================================================</a><br>

>> --- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)<br>
>> +++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Mon Feb  3 07:57:09 2014<br>
>> @@ -350,13 +350,23 @@ if (UNIX AND<br>
>>    append("-fcolor-diagnostics" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)<br>
>>  endif()<br>
>><br>
>> +# Clang prior to 3.5 ignored -fno-function-sections.<br>
>> +# It's pretty hard to test directly, so we rely on the version number.<br>
>> +if( ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) )<br>
>> +  set(LLVM_COMPILER_HAS_BROKEN_FNO_FUNCTION_SECTIONS ON)<br>
>> +endif()<br>
>> +<br>
><br>
> Please don't do it this way. Relying on version numbers to check for a<br>
> feature is the wrong thing to do. It doesn't account for the 5000<br>
> revisions that are called 3.5 and don't support this flag and just<br>
> generally isn't nice to packagers.<br>
><br>
> It also wouldn't be very scalable if other compilers needed to be<br>
> handled as well, though that doesn't seem to be the case in this<br>
> particular example.<br>
><br>
> Can't we check if the compiler supports the flag directly?<br>
><br>
>>  # Add flags for add_dead_strip().<br>
>>  # FIXME: With MSVS, consider compiling with /Gy and linking with /OPT:REF?<br>
>>  # But MinSizeRel seems to add that automatically, so maybe disable these<br>
>>  # flags instead if LLVM_NO_DEAD_STRIP is set.<br>
>>  if(NOT CYGWIN AND NOT WIN32)<br>
>>    if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")<br>
>> -    append("-ffunction-sections -fdata-sections" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)<br>
>> +    # Don't add -ffunction-section if it can be disabled with -fno-function-sections.<br>
>> +    # Doing so will break sanitizers.<br>
>> +    if (NOT LLVM_COMPILER_HAS_BROKEN_FNO_FUNCTION_SECTIONS)<br>
>> +      append("-ffunction-sections -fdata-sections" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)<br>
>> +    endif()<br>
>>    endif()<br>
>>  endif()<br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> llvm-commits mailing list<br>
>> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div>
</div>