diff --git a/doc/src/reference.xml b/doc/src/reference.xml index 20b5dc958..648cc2bd6 100644 --- a/doc/src/reference.xml +++ b/doc/src/reference.xml @@ -769,6 +769,32 @@ path-constant DATA : data/a.txt ; + c++-template-depth + 64-bit compilation + + + Allowed values: Any positive + integer. + + + + This feature allows configuring a C++ compiler with the maximal + template instantiation depth parameter. Exact default values as well + as whether this feature is supported at all depend on the toolset + used. + + + + Note: Due to some internal details + in the current Boost Build implementation it is not possible to have + features whose valid values are all positive integer. As a + workaround a large set of allowed values has been defined for this + feature and, if a different one is needed, user can easily add it by + calling the feature.extend rule. + + + + diff --git a/src/tools/builtin.jam b/src/tools/builtin.jam index 814365ae3..13a7bf272 100644 --- a/src/tools/builtin.jam +++ b/src/tools/builtin.jam @@ -15,6 +15,7 @@ import toolset : flags ; import errors : error ; import generate ; import generators ; +import numbers ; import os ; import print ; import project ; @@ -146,6 +147,33 @@ feature.feature warnings-as-errors : on # Fail the compilation if there are warnings. : incidental propagated ; +# Feature that allows us to configure the maximal template instantiation depth +# level allowed by a C++ compiler. Applies only to C++ toolsets whose compilers +# actually support this configuration setting. +# +# Note that Boost Build currently does not allow defining features that take any +# positive integral value as a parameter, which is what we need here, so we just +# define some of the values here and leave it up to the user to extend this set +# as he needs using the feature.extend rule. +# +# If a specific toolset requires a default value for this feature other than the +# one defined here it should set the feature's default value using the +# feature.set-default rule. +# +# TODO: This should be upgraded as soon as Boost Build adds support for custom +# validated feature values or at least features allowing any positive integral +# value. See related Boost Build related trac ticket #194. +# +feature.feature c++-template-depth + : + [ numbers.range 128 1024 : 128 ] + [ numbers.range 20 1000 : 10 ] + # Maximum template instantiation depth guaranteed for ANSI/ISO C++ + # conforming programs. + 17 + : + incidental propagated ; + feature.feature source : : free dependency incidental ; feature.feature library : : free dependency incidental ; feature.feature file : : free dependency incidental ; diff --git a/src/tools/gcc.jam b/src/tools/gcc.jam index 09a94387e..7f6920431 100644 --- a/src/tools/gcc.jam +++ b/src/tools/gcc.jam @@ -345,6 +345,8 @@ flags gcc.compile USER_OPTIONS ; flags gcc.compile.c++ USER_OPTIONS ; flags gcc.compile DEFINES ; flags gcc.compile INCLUDES ; +flags gcc.compile.c++ TEMPLATE_DEPTH ; + actions compile.c++.pch { @@ -381,7 +383,7 @@ rule compile.c actions compile.c++ bind PCH_FILE { - "$(CONFIG_COMMAND)" $(LANG) -ftemplate-depth-128 $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<:W)" "$(>:W)" + "$(CONFIG_COMMAND)" $(LANG) -ftemplate-depth-$(TEMPLATE_DEPTH) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<:W)" "$(>:W)" } actions compile.c bind PCH_FILE diff --git a/src/tools/qcc.jam b/src/tools/qcc.jam index 91968ab5b..390c36aef 100644 --- a/src/tools/qcc.jam +++ b/src/tools/qcc.jam @@ -79,10 +79,13 @@ flags qcc.compile INCLUDES ; flags qcc.compile OPTIONS shared : -shared ; +flags qcc.compile.c++ TEMPLATE_DEPTH ; +feature.set-default c++-template-depth : 100 ; + actions compile.c++ { - "$(CONFIG_COMMAND)" -Wc,-ftemplate-depth-100 $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" + "$(CONFIG_COMMAND)" -Wc,-ftemplate-depth-$(TEMPLATE_DEPTH) $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" } actions compile.c