diff --git a/doc/src/reference.adoc b/doc/src/reference.adoc index 18ca34507..12c926824 100644 --- a/doc/src/reference.adoc +++ b/doc/src/reference.adoc @@ -254,6 +254,7 @@ include::../../src/tools/features/rtti-feature.jam[tag=doc] include::../../src/tools/features/runtime-feature.jam[tag=doc] include::../../src/tools/features/search-feature.jam[tag=doc] include::../../src/tools/features/source-feature.jam[tag=doc] +include::../../src/tools/features/stdlib-feature.jam[tag=doc] include::../../src/tools/features/strip-feature.jam[tag=doc] include::../../src/tools/features/dll-feature.jam[tag=suppress-doc] include::../../src/tools/features/tag-feature.jam[tag=doc] diff --git a/src/tools/clang-darwin.jam b/src/tools/clang-darwin.jam index eb1ebce6a..11f62d298 100644 --- a/src/tools/clang-darwin.jam +++ b/src/tools/clang-darwin.jam @@ -99,6 +99,13 @@ toolset.flags clang-darwin.link OPTIONS on/thin : -flto=thin ; toolset.flags clang-darwin.compile OPTIONS on/full : -flto=full ; toolset.flags clang-darwin.link OPTIONS on/full : -flto=full ; +# stdlib selection +toolset.flags clang-darwin.compile OPTIONS gnu gnu11 : -stdlib=libstdc++ ; +toolset.flags clang-darwin.link OPTIONS gnu gnu11 : -stdlib=libstdc++ ; + +toolset.flags clang-darwin.compile OPTIONS libc++ : -stdlib=libc++ ; +toolset.flags clang-darwin.link OPTIONS libc++ : -stdlib=libc++ ; + actions compile.c { "$(CONFIG_COMMAND)" -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" diff --git a/src/tools/clang-linux.jam b/src/tools/clang-linux.jam index 8314ff3b6..13b34552c 100644 --- a/src/tools/clang-linux.jam +++ b/src/tools/clang-linux.jam @@ -123,6 +123,13 @@ toolset.flags clang-linux.link OPTIONS on/thin : -flto=thin ; toolset.flags clang-linux.compile OPTIONS on/full : -flto=full ; toolset.flags clang-linux.link OPTIONS on/full : -flto=full ; +# stdlib selection +toolset.flags clang-linux.compile OPTIONS gnu gnu11 : -stdlib=libstdc++ ; +toolset.flags clang-linux.link OPTIONS gnu gnu11 : -stdlib=libstdc++ ; + +toolset.flags clang-linux.compile OPTIONS libc++ : -stdlib=libc++ ; +toolset.flags clang-linux.link OPTIONS libc++ : -stdlib=libc++ ; + ############################################################################### # C and C++ compilation diff --git a/src/tools/features/stdlib-feature.jam b/src/tools/features/stdlib-feature.jam index 2dda4804c..b280ac8d0 100644 --- a/src/tools/features/stdlib-feature.jam +++ b/src/tools/features/stdlib-feature.jam @@ -3,10 +3,27 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -# TODO: Documentation. - import feature ; +#| tag::doc[] + +[[bbv2.builtin.features.stdlib]]`stdlib`:: +*Allowed values*: `native`, `gnu`, `gnu11`, `libc++`, `sun-stlport`, `apache`. ++ +Specifies C++ standard library to link to and in some cases the library ABI to +use: ++ +`native`::: Use compiler's default. +`gnu`::: Use GNU Standard Library (a.k.a. pass:[libstdc++]) with the old ABI. +`gnu11`::: Use GNU Standard Library with the new ABI. +`libc++`::: Use LLVM pass:[libc++]. +`sun-stlport`::: Use the STLport implementation of the standard library + provided with the Solaris Studio compiler. +`apache`::: Use the Apache stdcxx version 4 C++ standard library provided with + the Solaris Studio compiler. + +|# # end::doc[] + feature.feature stdlib - : native + : native gnu gnu11 libc++ sun-stlport apache : propagated composite ; diff --git a/src/tools/gcc.jam b/src/tools/gcc.jam index 47de21f89..15d1e0061 100644 --- a/src/tools/gcc.jam +++ b/src/tools/gcc.jam @@ -755,6 +755,9 @@ toolset.flags gcc.link OPTIONS on/full : -flto ; toolset.flags gcc.compile OPTIONS on/fat : -flto -ffat-lto-objects ; toolset.flags gcc.link OPTIONS on/fat : -flto ; +# ABI selection +toolset.flags gcc.compile.c++ DEFINES gnu : _GLIBCXX_USE_CXX11_ABI=0 ; +toolset.flags gcc.compile.c++ DEFINES gnu11 : _GLIBCXX_USE_CXX11_ABI=1 ; ### ### User free feature options. diff --git a/src/tools/sun.jam b/src/tools/sun.jam index 68533b7e0..f09e00ccc 100644 --- a/src/tools/sun.jam +++ b/src/tools/sun.jam @@ -73,40 +73,13 @@ generators.override sun.prebuilt : builtin.lib-generator ; generators.override sun.prebuilt : builtin.prebuilt ; generators.override sun.searched-lib-generator : searched-lib-generator ; -# -# There are no less than 5 standard library options: -# 1) The default, which uses an old version of the Rogue Wave std lib, -# also available via -std=sun03. -# 2) C++03 mode + STLport, selected via the -library option. -# 3) C++03 mode plus the Apache std lib, selected via the -library option. -# 4) C++03 or C++11 in g++ compatibility mode, and GNU libstdc++3, selected via -std=c++03/11. -# -# Note that the -std, -library and -compat compiler switches appear to be largely mutually -# incompatible, and that going forward the -std switch seems to be the preferred one. -# -# See http://docs.oracle.com/cd/E37069_01/html/E37075/bkamw.html#OSSCPgnaof -# -feature.extend stdlib : sun-stlport ; -feature.compose sun-stlport - : -library=stlport4 -compat=5 -features=zla - -library=stlport4 -compat=5 - ; -feature.extend stdlib : apache ; -feature.compose apache - : -library=stdcxx4 -compat=5 -features=zla - -library=stdcxx4 -compat=5 - ; -feature.extend stdlib : gnu ; -feature.compose gnu - : -std=c++03 -std=c++03 - ; -rule init ( version ? : command * : options * ) +rule init ( version ? : command * : options * ) { - local condition = [ + local condition = [ common.check-init-parameters sun : version $(version) ] ; - - command = [ common.get-invocation-command sun : CC + + command = [ common.get-invocation-command sun : CC : $(command) : "/opt/SUNWspro/bin" ] ; # Even if the real compiler is not found, put CC to @@ -114,7 +87,7 @@ rule init ( version ? : command * : options * ) command ?= CC ; common.handle-options sun : $(condition) : $(command) : $(options) ; - + command_c = $(command[1--2]) $(command[-1]:B=cc) ; toolset.flags sun CONFIG_C_COMMAND $(condition) : $(command_c) ; @@ -141,6 +114,33 @@ flags sun.compile OPTIONS global : -xldscope=global ; flags sun.compile.c++ OPTIONS off : +d ; +# There are no less than 5 standard library options: +# 1) The default, which uses an old version of the Rogue Wave std lib, +# also available via -std=sun03. +# 2) C++03 mode + STLport, selected via the -library option. +# 3) C++03 mode plus the Apache std lib, selected via the -library option. +# 4) C++03 or C++11 in g++ compatibility mode, and GNU libstdc++3, selected via -std=c++03/11. +# +# Note that the -std, -library and -compat compiler switches appear to be largely mutually +# incompatible, and that going forward the -std switch seems to be the preferred one. +# +# See http://docs.oracle.com/cd/E37069_01/html/E37075/bkamw.html#OSSCPgnaof +# + +flags sun.compile.c++ OPTIONS sun-stlport : -library=stlport4 -compat=5 -features=zla ; +flags sun.link OPTIONS sun-stlport : -library=stlport4 -compat=5 ; + +flags sun.compile.c++ OPTIONS apache : -library=stdcxx4 -compat=5 -features=zla ; +flags sun.link OPTIONS apache : -library=stdcxx4 -compat=5 ; + +flags sun.compile.c++ OPTIONS gnu : -std=c++03 ; +flags sun.compile.c++ DEFINES gnu : _GLIBCXX_USE_CXX11_ABI=0 ; +flags sun.link OPTIONS gnu : -std=c++03 ; + +flags sun.compile.c++ OPTIONS gnu11 : -std=c++11 ; +flags sun.compile.c++ DEFINES gnu11 : _GLIBCXX_USE_CXX11_ABI=1 ; +flags sun.link OPTIONS gnu11 : -std=c++11 ; + # The -m32 and -m64 options are supported starting # with Sun Studio 12. On earlier compilers, the # 'address-model' feature is not supported and should not