<div dir="ltr">Ouch. Sorry about that, George.<div><br></div><div>I definitely think the XRay CMake configurations should be using as many re-usable functions as possible, if they already exist. Unfortunately am not well-versed enough about what's in AddCompilerRT.cmake and/or what CMake already does. :(</div><div><br></div><div>This is mostly cargo-culting from surrounding CMake configs, and me crossing fingers to hope that things aren't that broken in platforms I don't regularly test/build with.</div><div><br></div><div>All the help in cleaning this up would be greatly appreciated.</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Apr 12, 2018 at 4:05 AM George Karpenkov <<a href="mailto:ekarpenkov@apple.com">ekarpenkov@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Dean,<br>
<br>
I have fixed the build failure in r329832. <br>
<br>
In general, do you think it would be possible to perform the task using higher-level functions available from AddCompilerRT.cmake?<br>
They were written exactly to avoid such errors.<br>
<br>
Regards,<br>
George<br>
<br>
> On Apr 11, 2018, at 10:50 AM, George Karpenkov <<a href="mailto:ekarpenkov@apple.com" target="_blank">ekarpenkov@apple.com</a>> wrote:<br>
> <br>
> Hi Dean,<br>
> <br>
> For me the build is still broken:<br>
> <br>
> -- Builtin supported architectures: i386;x86_64;x86_64h<br>
> CMake Error at projects/compiler-rt/lib/xray/tests/CMakeLists.txt:21 (add_library):<br>
>  add_library cannot create target "RTXRay.test.osx" because another target<br>
>  with the same name already exists.  The existing target is a static library<br>
>  created in source directory<br>
>  "/Volumes/Transcend/code/llvm/projects/compiler-rt/lib/xray/tests".  See<br>
>  documentation for policy CMP0002 for more details.<br>
> Call Stack (most recent call first):<br>
>  projects/compiler-rt/lib/xray/tests/CMakeLists.txt:73 (add_xray_lib)<br>
> <br>
> Do you think you could take a look?<br>
> <br>
> Regards,<br>
> George<br>
> <br>
>> On Apr 10, 2018, at 10:16 PM, Dean Michael Berris via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
>> <br>
>> Author: dberris<br>
>> Date: Tue Apr 10 22:16:11 2018<br>
>> New Revision: 329776<br>
>> <br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=329776&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=329776&view=rev</a><br>
>> Log:<br>
>> [XRay][compiler-rt] Fix osx-based builds<br>
>> <br>
>> This is a follow-up to D45474.<br>
>> <br>
>> Modified:<br>
>>   compiler-rt/trunk/lib/xray/tests/CMakeLists.txt<br>
>> <br>
>> Modified: compiler-rt/trunk/lib/xray/tests/CMakeLists.txt<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/tests/CMakeLists.txt?rev=329776&r1=329775&r2=329776&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/tests/CMakeLists.txt?rev=329776&r1=329775&r2=329776&view=diff</a><br>
>> ==============================================================================<br>
>> --- compiler-rt/trunk/lib/xray/tests/CMakeLists.txt (original)<br>
>> +++ compiler-rt/trunk/lib/xray/tests/CMakeLists.txt Tue Apr 10 22:16:11 2018<br>
>> @@ -34,13 +34,18 @@ function(get_xray_lib_for_arch arch lib)<br>
>> endfunction()<br>
>> <br>
>> set(XRAY_TEST_ARCH ${XRAY_SUPPORTED_ARCH})<br>
>> +set(XRAY_UNITTEST_LINK_FLAGS ${CMAKE_THREAD_LIBS_INIT})<br>
>> +if (NOT APPLE)<br>
>> +  append_list_if(COMPILER_RT_HAS_LIBM -lm XRAY_UNITTEST_LINK_FLAGS)<br>
>> +  append_list_if(COMPILER_RT_HAS_LIBRT -lrt XRAY_UNITTEST_LINK_FLAGS)<br>
>> +  append_list_if(COMPILER_RT_HAS_LIBDL -ldl XRAY_UNITTEST_LINK_FLAGS)<br>
>> +  append_list_if(COMPILER_RT_HAS_LIBPTHREAD -pthread XRAY_UNITTEST_LINK_FLAGS)<br>
>> +endif()<br>
>> +<br>
>> macro(add_xray_unittest testname)<br>
>>  cmake_parse_arguments(TEST "" "" "SOURCES;HEADERS" ${ARGN})<br>
>>  if(UNIX AND NOT APPLE)<br>
>>    set(CMAKE_DL_LIBS_INIT "")<br>
>> -    foreach(lib ${CMAKE_DL_LIBS})<br>
>> -      list(APPEND CMAKE_DL_LIBS_INIT -l${lib})<br>
>> -    endforeach()<br>
>>    foreach(arch ${XRAY_TEST_ARCH})<br>
>>      set(TEST_OBJECTS)<br>
>>      get_xray_lib_for_arch(${arch} XRAY_RUNTIME_LIBS)<br>
>> @@ -55,9 +60,7 @@ macro(add_xray_unittest testname)<br>
>>        RUNTIME "${XRAY_RUNTIME_LIBS}"<br>
>>        DEPS gtest xray<br>
>>        CFLAGS ${XRAY_UNITTEST_CFLAGS}<br>
>> -        LINK_FLAGS ${TARGET_LINK_FLAGS}<br>
>> -          -lstdc++ -lm ${CMAKE_THREAD_LIBS_INIT}<br>
>> -          ${CMAKE_DL_LIBS_INIT} -lrt)<br>
>> +        LINK_FLAGS ${TARGET_LINK_FLAGS} ${XRAY_UNITTEST_LINK_FLAGS} -lstdc++)<br>
>>      set_target_properties(XRayUnitTests<br>
>>        PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})<br>
>>    endforeach()<br>
>> @@ -66,11 +69,19 @@ endmacro()<br>
>> <br>
>> if(COMPILER_RT_CAN_EXECUTE_TESTS)<br>
>>  foreach(arch ${XRAY_SUPPORTED_ARCH})<br>
>> -    add_xray_lib("RTXRay.test.${arch}"<br>
>> -      $<TARGET_OBJECTS:RTXray.${arch}><br>
>> -      $<TARGET_OBJECTS:RTXrayFDR.${arch}><br>
>> -      $<TARGET_OBJECTS:RTSanitizerCommon.${arch}><br>
>> -      $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>)<br>
>> +    if (APPLE)<br>
>> +      add_xray_lib("RTXRay.test.osx"<br>
>> +        $<TARGET_OBJECTS:RTXray.osx><br>
>> +        $<TARGET_OBJECTS:RTXrayFDR.osx><br>
>> +        $<TARGET_OBJECTS:RTSanitizerCommon.osx><br>
>> +        $<TARGET_OBJECTS:RTSanitizerCommonLibc.osx>)<br>
>> +    else()<br>
>> +      add_xray_lib("RTXRay.test.${arch}"<br>
>> +        $<TARGET_OBJECTS:RTXray.${arch}><br>
>> +        $<TARGET_OBJECTS:RTXrayFDR.${arch}><br>
>> +        $<TARGET_OBJECTS:RTSanitizerCommon.${arch}><br>
>> +        $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>)<br>
>> +    endif()<br>
>>  endforeach()<br>
>>  add_subdirectory(unit)<br>
>> endif()<br>
>> <br>
>> <br>
>> _______________________________________________<br>
>> llvm-commits mailing list<br>
>> <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
> <br>
<br>
</blockquote></div>