I'm going to go ahead and respond here and make it a pinned topic. This is by far the biggest comment I get from users.
Things to consider regarding ChaiScript build performance.
- As of ~February of 2015 any increase in build times is considered a regression. It is something that is being actively considered. The 5.7.1 release of ChaiScript decreased build times across the board. At the time of writing this, MSVC 2015 is much faster build times than either clang or gcc.
- ChaiScript is a header-only library. This means that every time you compile a project using it you are compiling an entire scripting language and all of its supporting libraries. Do you know of any other computer language that compiles in a minute or less?
Does being header only make sense? Maybe. It makes ChaiScript very easy to include in your project. Most of ChaiScript is lots and lots of C++ template magic. Even if we had a compiled portion of it (which we do, it's the
chaiscript_stdlib, actually using ChaiScript in your application asks a lot of the compiler.
At runtime, if not explicitly provided with its runtime library, ChaiScript attempts to find a dll/so that contains its standard library.
This is the difference between the basic and compiled in examples. The first looks for the chaiscript dll, the second does not.
Critical Note: If you are using the "basic" example you must provide chaiscript with a build of the stdlib that PERFECTLY matches every compile option as the rest of your project.
For this reason we do not recommend actually using the loadable stdlib feature
Instead we recommend that you use the feature to break up how ChaiScript is compiled and constructed inside of your project.
What To Do?
Split up the compilation of ChaiScript into 3 basic parts:
- The construction of the ChaiScript object itself
- The construction of the ChaiScript StdLib
- The construction of your application's specific bindings
A demonstration of how to do this, along with code examples is available in the ChaiScript "Spiced" game engine:
chaiscript_bindings.* define the game engine's bindings for chaiscript
chaiscript_stdlib.* creates and returns the ChaiScript standard library
chaiscript_creator.* defines and returns a
chaiscript::ChaiScript object that has been initialized with the objects created in the
This allows for the build to be parallelized and only the parts that need to be compiled are compiled during each iterative build.
Furthermore, you can break up your "bindings" files into multiple files if you have frequently changing vs stable headers that you need to wrap.
On my system (7 cores) building all of Spiced takes 28 seconds (debug build gcc 4.8.4) while building just the "chaiscript_bindings" file takes 16 seconds.