<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 20, 2014 at 10:12 PM, Greg Fitzgerald <span dir="ltr"><<a href="mailto:garious@gmail.com" target="_blank">garious@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> ExternalProject_Add(compiler-rt ...)<br>
<br>
So that was quite the experiment.  Looking at<br>
clang/runtime/CMakeLists.txt, I'm not seeing a lot of bang for buck<br>
here, and it looks like this file is prone to bit rot.</blockquote><div><br></div><div>Could you please elaborate on this? In fact, I don't plan to give up on this experiment.</div><div>On the contrary, I wanted to move LLVM_BUILD_EXTERNAL_COMPILER_RT to the</div>
<div>bots, migrate the workflow of our team to use this mode, and eventually make it the default.</div><div><br></div><div>The problem is that we want top-level targets from compiler-rt build tree be visible in the llvm/clang</div>
<div>top-level build tree. I thought this could be achieved by ugly propagation of top-level compiler-rt</div><div>targets with add_custom_target() command. (like I did this for check-compiler-rt command).</div><div><br></div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">  I think we<br>
should consider punting on this one and looking for a more incremental<br>
strategy.  For instance, how about starting by moving the call<br>
'add_llvm_external_project(compiler-rt)' from<br>
llvm/projects/CMakesLists.txt to clang/runtime?  We can tweak this<br>
macro (or a clang variant) to optionally do something like:<br>
<br>
    include(AddCompilerRt)<br>
<br>
That way if CMAKE_PREFIX_PATH includes a path to the compiler-rt<br>
install directory, it can import all the same build targets that would<br>
be created by add_subdirectory(compiler-rt).<br></blockquote><div><br></div><div>Probably I don't understand how CMAKE_PREFIX_PATH works. How can top-level</div><div>targets from one build tree be visible in another build tree?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
If I were to use CMake's ExternalProject feature, it would be from a<br>
top-level superproject.  I would use it to manage dependencies and to<br>
populate CMAKE_PREFIX_PATH for each dependency.  CMake, Make or a<br>
package manager, it wouldn't matter which you used for this part (I've<br>
used Make for this).  Ultimately, you want to end up with a top-level<br>
build that performs the following:<br>
<br>
    mkdir -p llvm/out && cd llvm/out<br>
    cmake .. -DCMAKE_INSTALL_PREFIX=ship<br>
    ninja check-all install<br>
    cd -<br>
<br>
    mkdir -p compiler-rt/out && cd compiler-rt/out<br>
    cmake .. -DCMAKE_PREFIX_PATH=`pwd`/../../llvm/out/ship<br>
-DCMAKE_INSTALL_PREFIX=ship<br>
    ninja check-all install<br>
    cd -<br>
<br>
    mkdir -p clang/out && cd clang/out<br>
    cmake ..  -DCMAKE_PREFIX_PATH=`pwd`/../../llvm/out/ship:`pwd`/../../compiler-rt/out/ship<br>
-DCMAKE_INSTALL_PREFIX=ship<br>
    ninja check-all install<br>
    cd -<br>
<br>
In this scenario, the compiler-rt build creates a cmake module that<br>
clang includes.  It uses that cmake module to find the compiler-rt<br>
install targets and copy them into "lib/clang/<version>".  The clang<br>
build then calls 'add_subdirectory' on the compiler-rt 'test'<br>
directory, pointing it to the just-built-clang.  So the dependency<br>
tree for clang is:<br>
<br>
    sanitizer-tests -> clang -> compiler-rt -> c-compiler<br></blockquote><div><br></div><div><br></div><div>... But we want to build compiler-rt libraries with just-built Clang as well. This is what</div><div>Makefile-based build does, and what we can benefit from.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thoughts?<br>
<br>
Thanks,<br>
Greg<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Thu, Feb 27, 2014 at 1:19 AM, Alexey Samsonov <<a href="mailto:samsonov@google.com">samsonov@google.com</a>> wrote:<br>
><br>
> On Wed, Feb 26, 2014 at 9:58 PM, Brad King <<a href="mailto:brad.king@kitware.com">brad.king@kitware.com</a>> wrote:<br>
>><br>
>> On 02/26/2014 12:43 PM, Alexey Samsonov wrote:<br>
>> > Do you think it makes sense to land my ExternalProject_Add patch<br>
>> > so that others can experiment with it? I can add quit with a<br>
>> > fatal_error/warning if the build tree rules are generated with Ninja.<br>
>><br>
>> Since it is conditional on LLVM_BUILD_EXTERNAL_COMPILER_RT, yes.<br>
><br>
><br>
> Submitted as r202367.<br>
><br>
>><br>
>><br>
>> > parallelism doesn't work when I run "make check-compiler-rt -j8"<br>
>> > in the original build tree, presumably because we call<br>
>> > "cd /path/to/compiler-rt/build/tree && make check-all" there.<br>
>><br>
>> Right.  The ExternalProject module has a special case for the<br>
>> Makefile generators to make with $(MAKE) instead of "make":<br>
>><br>
>><br>
>> <a href="http://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/ExternalProject.cmake;hb=v2.8.12.2#l846" target="_blank">http://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/ExternalProject.cmake;hb=v2.8.12.2#l846</a><br>

>><br>
>> so that flags like -j propagate automatically.  You could do<br>
>> that too:<br>
>><br>
>>   if(CMAKE_GENERATOR MATCHES "Make")<br>
>>     set(check_compiler_rt "$(MAKE)" "check-all")<br>
>>   else()<br>
>>     set(check_compiler_rt ${CMAKE_COMMAND} --build .<br>
>>       --target check-all --config $<CONFIGURATION>)<br>
>>   endif()<br>
>><br>
>>   ExternalProject_Get_Property(compiler-rt BINARY_DIR)<br>
>>   add_custom_target(check-compiler-rt<br>
>>     COMMAND ${check_compiler_rt}<br>
>>     DEPENDS compiler-rt<br>
>>     WORKING_DIRECTORY ${BINARY_DIR}<br>
>>     VERBATIM<br>
>>     )<br>
>><br>
><br>
> This worked, thanks! Currently I also print fatal_error message if I detect<br>
> Ninja as a CMAKE_GENERATOR.<br>
><br>
><br>
> --<br>
> Alexey Samsonov, MSK<br>
><br>
</div></div><div class="HOEnZb"><div class="h5">> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div>
</div></div>