The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=15555 
====================================================================== 
Reported By:                Todd Lipcon
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15555
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-05-05 17:49 EDT
Last Modified:              2015-05-05 17:49 EDT
====================================================================== 
Summary:                    Ninja: C compilation targets unnecessarily depend on
libraries
Description: 
When the Ninja generator generates targets for .cc files, it adds dependencies
on any libraries that their target depend on. This means that in a parallel
build, ninja won't start building any .cc files from one library until all
depended-upon libraries have been built -- an unnecessary restriction. The only
requirement should be that a target cannot be _linked_ until its required
libraries are built.

This severely limits build parallelism in large projects. I manually
post-processed a build.ninja file from a medium-size C++ project to remove these
dependencies, and a parallel build using icecc on a small cluster was reduced
from 1m30s to 1m0s. Looking at a Gantt chart of the build, I could see that all
of the cluster cores were kept occupied much better after the fix, especially at
the start of the build.

Steps to Reproduce: 
todd@todd-ThinkPad-T540p:/tmp/test$ cat foo.cc 
extern int bar();
int main() {
  return bar();
}
todd@todd-ThinkPad-T540p:/tmp/test$ cat bar.cc 
int bar() {
  return 1;
}
todd@todd-ThinkPad-T540p:/tmp/test$ cat CMakeLists.txt 
add_library(bar bar.cc)
add_executable(foo foo.cc)
target_link_libraries(foo bar)
todd@todd-ThinkPad-T540p:/tmp/test$ cmake -GNinja .
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/test
todd@todd-ThinkPad-T540p:/tmp/test$ grep 'build.*foo.cc.o:' build.ninja 
build CMakeFiles/foo.dir/foo.cc.o: CXX_COMPILER foo.cc || libbar.a


I attached the above directory to this bug report.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-05-05 17:49 Todd Lipcon    New Issue                                    
2015-05-05 17:49 Todd Lipcon    File Added: test.tar.gz                      
======================================================================

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to