diff --git a/doc/src/reference.adoc b/doc/src/reference.adoc index 8027b65f7..77bca0715 100644 --- a/doc/src/reference.adoc +++ b/doc/src/reference.adoc @@ -533,7 +533,7 @@ The supported values have the following meaning: + * `global` - a.k.a. "default" in gcc documentation. Global symbols are considered public, they are exported from shared libraries and can be redefined by another - shared library or executable. This is the default value. + shared library or executable. * `protected` - a.k.a. "symbolic". Protected symbols are exported from shared libraries but cannot be redefined by another shared library or executable. This mode is not supported on some platforms, for example OS X. @@ -541,6 +541,25 @@ The supported values have the following meaning: be redefined by a different shared library or executable loaded in a process. In this mode, public symbols have to be explicitly marked in the source code to be exported from shared libraries. This is the recommended mode. ++ +By default compiler default visibility mode is used (no compiler flags are added). ++ +NOTE: In Boost superproject Jamroot file this property is set to the default +value of `hidden`. This means that Boost libraries are built with hidden +visibility by default, unless the user overrides it with a different `visibility` +or a library sets a different `local-visibility` (see below). + +[[bbv2.builtin.features.local-visibility]]`local-visibility`:: +*Allowed values:* `global`, `protected`, `hidden`. ++ +This feature has the same effect as the `visibility` feature but is intended +to be used by targets that require a particular symbol visibility. Unlike +the `visibility` feature, `local-visibility` is not inherited by the target +dependencies and only affects the target to which it is applied. ++ +The `local-visibility` feature supports the same values with the same meaning +as the `visibility` feature. By default, if `local-visibility` is not specified +for a target, the value of the `visibility` feature is used. [[bbv2.reference.tools]] == Builtin tools diff --git a/src/tools/features/local-visibility-feature.jam b/src/tools/features/local-visibility-feature.jam new file mode 100644 index 000000000..ff07dc92f --- /dev/null +++ b/src/tools/features/local-visibility-feature.jam @@ -0,0 +1,10 @@ +# Copyright 2018 Andrey Semashev +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import feature ; + +feature.feature local-visibility + : global protected hidden + : optional ; diff --git a/src/tools/features/visibility-feature.jam b/src/tools/features/visibility-feature.jam index 5349b1deb..957a7220c 100644 --- a/src/tools/features/visibility-feature.jam +++ b/src/tools/features/visibility-feature.jam @@ -7,4 +7,8 @@ import feature ; feature.feature visibility : global protected hidden - : optional ; + : optional composite propagated ; + +feature.compose global : global ; +feature.compose protected : protected ; +feature.compose hidden : hidden ; diff --git a/src/tools/gcc.jam b/src/tools/gcc.jam index 802ea7c90..4e850b163 100644 --- a/src/tools/gcc.jam +++ b/src/tools/gcc.jam @@ -718,11 +718,11 @@ toolset.flags gcc.compile OPTIONS on : -Werror ; toolset.flags gcc.compile OPTIONS on : -g ; toolset.flags gcc.compile OPTIONS on : -pg ; -toolset.flags gcc.compile OPTIONS hidden : -fvisibility=hidden ; -toolset.flags gcc.compile.c++ OPTIONS hidden : -fvisibility-inlines-hidden ; -toolset.flags gcc.compile OPTIONS protected : -fvisibility=protected ; -toolset.flags gcc.compile OPTIONS protected/darwin : ; -toolset.flags gcc.compile OPTIONS global : -fvisibility=default ; +toolset.flags gcc.compile OPTIONS hidden : -fvisibility=hidden ; +toolset.flags gcc.compile.c++ OPTIONS hidden : -fvisibility-inlines-hidden ; +toolset.flags gcc.compile OPTIONS protected : -fvisibility=protected ; +toolset.flags gcc.compile OPTIONS protected/darwin : ; +toolset.flags gcc.compile OPTIONS global : -fvisibility=default ; toolset.flags gcc.compile.c++ OPTIONS off : -fno-rtti ; toolset.flags gcc.compile.c++ OPTIONS off : -fno-exceptions ; @@ -862,10 +862,10 @@ toolset.flags gcc.link FINDLIBS-SA ; toolset.flags gcc.link LIBRARIES ; # Specify compile flags for linker as well as they may be needed for LTO -toolset.flags gcc.link OPTIONS hidden : -fvisibility=hidden -fvisibility-inlines-hidden ; -toolset.flags gcc.link OPTIONS protected : -fvisibility=protected ; -toolset.flags gcc.link OPTIONS protected/darwin : ; -toolset.flags gcc.link OPTIONS global : -fvisibility=default ; +toolset.flags gcc.link OPTIONS hidden : -fvisibility=hidden -fvisibility-inlines-hidden ; +toolset.flags gcc.link OPTIONS protected : -fvisibility=protected ; +toolset.flags gcc.link OPTIONS protected/darwin : ; +toolset.flags gcc.link OPTIONS global : -fvisibility=default ; toolset.flags gcc.link.dll .IMPLIB-COMMAND windows : "-Wl,--out-implib," ; toolset.flags gcc.link.dll .IMPLIB-COMMAND cygwin : "-Wl,--out-implib," ; diff --git a/src/tools/qcc.jam b/src/tools/qcc.jam index decb8aed7..155b1ac3d 100644 --- a/src/tools/qcc.jam +++ b/src/tools/qcc.jam @@ -65,10 +65,10 @@ toolset.flags qcc.compile OPTIONS on : -Wc,-Werror ; toolset.flags qcc.compile OPTIONS on : -p ; -toolset.flags qcc.compile OPTIONS hidden : -fvisibility=hidden ; -toolset.flags qcc.compile.c++ OPTIONS hidden : -fvisibility-inlines-hidden ; -toolset.flags qcc.compile OPTIONS protected : -fvisibility=protected ; -toolset.flags qcc.compile OPTIONS global : -fvisibility=default ; +toolset.flags qcc.compile OPTIONS hidden : -fvisibility=hidden ; +toolset.flags qcc.compile.c++ OPTIONS hidden : -fvisibility-inlines-hidden ; +toolset.flags qcc.compile OPTIONS protected : -fvisibility=protected ; +toolset.flags qcc.compile OPTIONS global : -fvisibility=default ; toolset.flags qcc.compile OPTIONS ; toolset.flags qcc.compile.c++ OPTIONS ; diff --git a/src/tools/sun.jam b/src/tools/sun.jam index 08b68ce30..68533b7e0 100644 --- a/src/tools/sun.jam +++ b/src/tools/sun.jam @@ -135,9 +135,9 @@ flags sun.compile OPTIONS on : -erroff=%none ; flags sun.compile OPTIONS all : -erroff=%none ; flags sun.compile OPTIONS on : -errwarn ; -flags sun.compile OPTIONS hidden : -xldscope=hidden ; -flags sun.compile OPTIONS protected : -xldscope=symbolic ; -flags sun.compile OPTIONS global : -xldscope=global ; +flags sun.compile OPTIONS hidden : -xldscope=hidden ; +flags sun.compile OPTIONS protected : -xldscope=symbolic ; +flags sun.compile OPTIONS global : -xldscope=global ; flags sun.compile.c++ OPTIONS off : +d ; diff --git a/src/tools/xlcpp.jam b/src/tools/xlcpp.jam index e3af93a55..6211f5f15 100644 --- a/src/tools/xlcpp.jam +++ b/src/tools/xlcpp.jam @@ -96,9 +96,9 @@ else flags xlcpp.compile CFLAGS shared : -qpic=large ; flags xlcpp FINDLIBS : rt ; - flags xlcpp.compile OPTIONS hidden : -qvisibility=hidden ; - flags xlcpp.compile OPTIONS protected : -qvisibility=protected ; - flags xlcpp.compile OPTIONS global : -qvisibility=default ; + flags xlcpp.compile OPTIONS hidden : -qvisibility=hidden ; + flags xlcpp.compile OPTIONS protected : -qvisibility=protected ; + flags xlcpp.compile OPTIONS global : -qvisibility=default ; } # Profiling