Rafael Espíndola
2014-Feb-27 01:08 UTC
[LLVMdev] Understanding some of the recent cmake build changes
I was a bit confused with what the difference was between the old target_link_libraries(foo bar) and the new target_link_libraries(foo INTERFACE|PRIVATE|PUBLIC bar) To try to find out, I decided to look at the generated build.ninja. The difference that shows up is far fewer order only dependencies. For example build lib/TableGen/CMakeFiles/LLVMTableGen.dir/Error.cpp.o: CXX_COMPILER /home/espindola/llvm/llvm/lib/TableGen/Error.cpp || lib/libLLVMSupport.a becomes just build lib/TableGen/CMakeFiles/LLVMTableGen.dir/Error.cpp.o: CXX_COMPILER /home/espindola/llvm/llvm/lib/TableGen/Error.cpp The net result is that in the old system running ninja ./lib/TableGen/CMakeFiles/LLVMTableGen.dir/Error.cpp.o on a tree just after running cmake would execute 91 commands to build lib/libLLVMSupport.a and then Error.cpp.o. On the new system only one command is executed :-) In a more realistic situation, Error.cpp.o will be compiled in parallel with the files needed to build lib/libLLVMSupport.a. Cheers, Rafael
Reid Kleckner
2014-Feb-27 01:19 UTC
[LLVMdev] Understanding some of the recent cmake build changes
Yep! This is awesome. I remember filing a CMake bug about this long ago, and it looks like this is the answer. On Wed, Feb 26, 2014 at 5:08 PM, Rafael Espíndola < rafael.espindola at gmail.com> wrote:> I was a bit confused with what the difference was between the old > > target_link_libraries(foo bar) > > and the new > > target_link_libraries(foo INTERFACE|PRIVATE|PUBLIC bar) > > To try to find out, I decided to look at the generated build.ninja. > The difference that shows up is far fewer order only dependencies. For > example > > build lib/TableGen/CMakeFiles/LLVMTableGen.dir/Error.cpp.o: > CXX_COMPILER /home/espindola/llvm/llvm/lib/TableGen/Error.cpp || > lib/libLLVMSupport.a > > becomes just > > build lib/TableGen/CMakeFiles/LLVMTableGen.dir/Error.cpp.o: > CXX_COMPILER /home/espindola/llvm/llvm/lib/TableGen/Error.cpp > > The net result is that in the old system running > > ninja ./lib/TableGen/CMakeFiles/LLVMTableGen.dir/Error.cpp.o > > on a tree just after running cmake would execute 91 commands to build > lib/libLLVMSupport.a and then Error.cpp.o. On the new system only one > command is executed :-) > > In a more realistic situation, Error.cpp.o will be compiled in > parallel with the files needed to build lib/libLLVMSupport.a. > > Cheers, > Rafael > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140226/3d4e1b28/attachment.html>
NAKAMURA Takumi
2014-Feb-27 14:29 UTC
[LLVMdev] Understanding some of the recent cmake build changes
Rafael, thanks to explain with clear examples. Although target_link_libraries(INTERFACE) can cut deps among libraries, files in add_executable() will be still serialized. For example, build tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/TableGen.cpp.o: CXX_COMPILER /home/chapuni/llvm-project/clang/utils/TableGen/TableGen.cpp || lib/libLLVMTableGen.a lib/libLLVMSupport.a If TableGen.cpp would be made free from *.a, we should introduce objlib stuff for add_executable(). See also my tddeps patch. 2014-02-27 10:08 GMT+09:00 Rafael Espíndola <rafael.espindola at gmail.com>:> I was a bit confused with what the difference was between the old > > target_link_libraries(foo bar) > > and the new > > target_link_libraries(foo INTERFACE|PRIVATE|PUBLIC bar) > > To try to find out, I decided to look at the generated build.ninja. > The difference that shows up is far fewer order only dependencies. For > example > > build lib/TableGen/CMakeFiles/LLVMTableGen.dir/Error.cpp.o: > CXX_COMPILER /home/espindola/llvm/llvm/lib/TableGen/Error.cpp || > lib/libLLVMSupport.a > > becomes just > > build lib/TableGen/CMakeFiles/LLVMTableGen.dir/Error.cpp.o: > CXX_COMPILER /home/espindola/llvm/llvm/lib/TableGen/Error.cpp > > The net result is that in the old system running > > ninja ./lib/TableGen/CMakeFiles/LLVMTableGen.dir/Error.cpp.o > > on a tree just after running cmake would execute 91 commands to build > lib/libLLVMSupport.a and then Error.cpp.o. On the new system only one > command is executed :-) > > In a more realistic situation, Error.cpp.o will be compiled in > parallel with the files needed to build lib/libLLVMSupport.a. > > Cheers, > Rafael
Rafael Espíndola
2014-Feb-27 14:54 UTC
[LLVMdev] Understanding some of the recent cmake build changes
On 27 February 2014 09:29, NAKAMURA Takumi <geek4civic at gmail.com> wrote:> Rafael, thanks to explain with clear examples. > > Although target_link_libraries(INTERFACE) can cut deps among > libraries, files in add_executable() will be still serialized. > For example, > > build tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/TableGen.cpp.o: > CXX_COMPILER /home/chapuni/llvm-project/clang/utils/TableGen/TableGen.cpp > || lib/libLLVMTableGen.a lib/libLLVMSupport.a > > If TableGen.cpp would be made free from *.a, we should introduce > objlib stuff for add_executable(). > See also my tddeps patch.Thanks for the example. I reported http://llvm.org/bugs/show_bug.cgi?id=18990 to track this. Cheers, Rafael