This is technically not a functional change because all symbols that
should be exported from the shared library are already marked with
explicit visibility annotations. However, applying this attribute
at the namespace scope will allow us to drop many visibility
annotations in the future, which is a nice simplification.
This commit also solves the problem of different symbols being exported
depending on the build mode in use (see PR38138). With this change, stray
symbols are not exported from the dylib due to implicit instantiations,
and as a result we export the same symbols in Debug and Release modes.