Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building all of Boost in a few minutes

Tags:

c++

boost

Can anyone explain why following these instructions:

http://www.boost.org/doc/libs/1_59_0/more/getting_started/unix-variants.html#easy-build-and-install

... it takes my decent machine 5 hours to build all of Boost, while some folks report doing the same in only 3 minutes ?

Is there another way to build Boost than the one mentioned above that indeed goes pretty quickly (compared to several hours, at any rate).

I am using the Clang compiler on Darwin (Mac) option. Not sure how relevant it is but I have 16 GB RAM and a recent SSD. The clock is 2.3 Ghz.

Edit: I'm happy to report, based on the comments and answers, that using the ./b2 -j4 -d0 options, I got my compilation time down to 13 minutes. Also the -jN option is not listed in the set of available options with the default --help, you must instead call --help-options to see these additional more "advanced" techniques.

like image 361
johnbakers Avatar asked Nov 06 '15 12:11

johnbakers


People also ask

How long it takes to build Boost?

Building the library and tests adds between 80 and 140 MB of object files and executables to this. On a Pentium III laptop, building the Boost library takes 15 minutes and building and running the regression tests takes an additional 5 minutes.

Do I need to compile Boost library?

Most Boost libraries are header-only: they consist entirely of header files containing templates and inline functions, and require no separately-compiled library binaries or special treatment when linking.

How do I add Boost?

Tap the Cash Card tab on your home screen. Press Save with Boost. Tap on a Boost. Tap Add Boost.

Is Boost process header-only?

Boost Process is header-only, so you don't have to compile it separately.


1 Answers

I just ran a few tests with a few different build configs.

Hardware: 2012 MacBook Pro (2.3Ghz Ivy Bridge i7 [i7-3615QM]), factory SSD and 16GB of ram.

Software: Mac OS X 10.11.1 with Xcode 7 (Apple LLVM version 7.0.0 clang-700.1.76). Fresh copy of Boost 1.59.0 from the website.

I tested the following build commands:

Default Build:

./bootstrap.sh && ./b2 -j N

Build forcing the linking of libc++

./bootstrap.sh && ./b2 toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" -j N

For each I tried three different values for N: 1 (single thread), 4 (matching physical cores), and 8 (matching hyperthreaded cores).

Default linking:

  • With 8 the build time was 6:45 minutes
  • With 4 the build time was 7:22 minutes
  • With 1 the build time was 22:58 minutes

Linking libc++:

  • With 8 the build time was 4:35 minutes
  • With 4 the build time was 5:45 minutes
  • With 1 the build time was 17:15 minutes

Conclusion: Boost shouldn't have to take all day to build on a multi-core system with an SSD even if it isn't brand new. Building with the default (singled thread) does take way longer than a parallel build. The Boost build with clang on OS X does benefit slightly from hyperthreading. Linking with libc++ seems a bit faster as well.

like image 76
zaphoyd Avatar answered Oct 11 '22 11:10

zaphoyd